# Frame per second
FPS = 30
-# Night length in ticks
+# Night length in ticks and hours
NIGHT_LENGTH = 1500
-# Night length in hours
NIGHT_LENGTH_HOURS = 12
+NIGHT_HOURS_PER_TICK = float(NIGHT_LENGTH_HOURS) / NIGHT_LENGTH
# Pymunk categories
OBSTACLE_CATEGORY = 1 << 0
"{gamestate.seeds} seeds",
"{scene.turnip_count} plants",
"battery {battery.current}/{battery.max}",
- "power usage {scene.power_usage}"
+ "power usage {scene.power_usage}/h"
])
self._font = loader.load_font(FONTS['sans'], size=20)
self._text = None
from ..loader import loader
from ..transforms import Overlay, Alpha, ColourWedges
-from ..constants import SCREEN_SIZE, FONTS, DEBUG
+from ..constants import SCREEN_SIZE, FONTS, FPS, NIGHT_HOURS_PER_TICK, DEBUG
from ..widgets import ImageButton
from ..turnip import Turnip, TurnipInvalidPosition, check_turnips
@property
def power_usage(self):
- return int(self._lights.total_power_usage())
+ power = self._lights.total_power_usage()
+ power = power / (FPS * NIGHT_HOURS_PER_TICK)
+ return int(round(power))
@debug_timer("day.render")
def render(self, surface, gamestate):
from ..turnip import Turnip
from ..widgets import ImageButton
from ..constants import (
- NIGHT_LENGTH, NIGHT_LENGTH_HOURS, DEBUG, FONTS, SCREEN_SIZE, FPS)
+ NIGHT_LENGTH, NIGHT_HOURS_PER_TICK, DEBUG, FONTS,
+ SCREEN_SIZE, FPS)
class NightScene(BaseScene):
DARKNESS = Overlay(colour=(0, 0, 0, 150))
- HOURS_PER_TICK = float(NIGHT_LENGTH_HOURS) / NIGHT_LENGTH
def enter(self, gamestate):
self._space = pymunk.Space()
@property
def power_usage(self):
- return int(self._lights.total_power_usage())
+ power = self._lights.total_power_usage()
+ power = power / (FPS * NIGHT_HOURS_PER_TICK)
+ return int(round(power))
def remaining_hours(self):
return int(round(
- (NIGHT_LENGTH - self._total_ticks) * self.HOURS_PER_TICK))
+ (NIGHT_LENGTH - self._total_ticks) * NIGHT_HOURS_PER_TICK))
@debug_timer("night.render")
def render(self, surface, gamestate):