projects
/
tabakrolletjie.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
48c8093
)
Display power usage per hour.
author
Simon Cross
<hodgestar@gmail.com>
Sat, 10 Sep 2016 19:18:08 +0000
(21:18 +0200)
committer
Simon Cross
<hodgestar@gmail.com>
Sat, 10 Sep 2016 19:18:08 +0000
(21:18 +0200)
tabakrolletjie/constants.py
patch
|
blob
|
history
tabakrolletjie/infobar.py
patch
|
blob
|
history
tabakrolletjie/scenes/day.py
patch
|
blob
|
history
tabakrolletjie/scenes/night.py
patch
|
blob
|
history
diff --git
a/tabakrolletjie/constants.py
b/tabakrolletjie/constants.py
index 0ea58f52a260aba732d68e84a8f8be7b2652bf0a..63e13dd63ebf6f53ec36567469642373203d263b 100644
(file)
--- a/
tabakrolletjie/constants.py
+++ b/
tabakrolletjie/constants.py
@@
-17,10
+17,10
@@
SCREEN_SIZE = (1024, 704)
# Frame per second
FPS = 30
# Frame per second
FPS = 30
-# Night length in ticks
+# Night length in ticks
and hours
NIGHT_LENGTH = 1500
NIGHT_LENGTH = 1500
-# Night length in hours
NIGHT_LENGTH_HOURS = 12
NIGHT_LENGTH_HOURS = 12
+NIGHT_HOURS_PER_TICK = float(NIGHT_LENGTH_HOURS) / NIGHT_LENGTH
# Pymunk categories
OBSTACLE_CATEGORY = 1 << 0
# Pymunk categories
OBSTACLE_CATEGORY = 1 << 0
diff --git
a/tabakrolletjie/infobar.py
b/tabakrolletjie/infobar.py
index ac9f1a95923f53b4aa1b5eb702428e617d6bfe94..6697892708fbfefba1eaf741e9050a7909b1ddaf 100644
(file)
--- a/
tabakrolletjie/infobar.py
+++ b/
tabakrolletjie/infobar.py
@@
-26,7
+26,7
@@
class InfoBar(object):
"{gamestate.seeds} seeds",
"{scene.turnip_count} plants",
"battery {battery.current}/{battery.max}",
"{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
])
self._font = loader.load_font(FONTS['sans'], size=20)
self._text = None
diff --git
a/tabakrolletjie/scenes/day.py
b/tabakrolletjie/scenes/day.py
index 1e65fe10794b0e3e05c2a97339df7672ecbcd702..cc7a32e1cf1b1b41cd2bb6508f90f9159fd597f5 100644
(file)
--- a/
tabakrolletjie/scenes/day.py
+++ b/
tabakrolletjie/scenes/day.py
@@
-19,7
+19,7
@@
from ..utils import debug_timer, shadowed_text
from ..loader import loader
from ..transforms import Overlay, Alpha, ColourWedges
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
from ..widgets import ImageButton
from ..turnip import Turnip, TurnipInvalidPosition, check_turnips
@@
-138,7
+138,9
@@
class DayScene(BaseScene):
@property
def power_usage(self):
@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):
@debug_timer("day.render")
def render(self, surface, gamestate):
diff --git
a/tabakrolletjie/scenes/night.py
b/tabakrolletjie/scenes/night.py
index e4cc73384b9c433f61755cfd16fe73a35226770f..580d140a6941475cfeefc1f295e2b51ec82312b7 100644
(file)
--- a/
tabakrolletjie/scenes/night.py
+++ b/
tabakrolletjie/scenes/night.py
@@
-18,13
+18,13
@@
from ..transforms import Overlay
from ..turnip import Turnip
from ..widgets import ImageButton
from ..constants import (
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))
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()
def enter(self, gamestate):
self._space = pymunk.Space()
@@
-69,11
+69,13
@@
class NightScene(BaseScene):
@property
def power_usage(self):
@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(
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):
@debug_timer("night.render")
def render(self, surface, gamestate):