""" Be prepared. """
import pygame.locals as pgl
-import pygame.surface
import pymunk
import pymunk.pygame_util
from ..events import SceneChangeEvent
from ..utils import debug_timer
from ..loader import loader
+from ..transforms import Overlay
from ..constants import SCREEN_SIZE, FONTS
from ..widgets import ImageButton
class DayScene(BaseScene):
+
+ BRIGHTNESS = Overlay(colour=(255, 255, 255, 50))
+
def enter(self, gamestate):
self._space = pymunk.Space()
self._toolbar_font = loader.load_font(FONTS['sans'], size=20)
pos=(SCREEN_SIZE[0] - 50, SCREEN_SIZE[1] - 40)),
]
self._update_toolbar(gamestate)
+ # Background
+ self._soil = loader.load_image(
+ "textures", "soil.png", transform=self.BRIGHTNESS)
def exit(self, gamestate):
self._unset_cursor()
@debug_timer("day.render")
def render(self, surface, gamestate):
- surface.blit(loader.load_image("textures", "soil.png"), (0, 0))
- brightness = pygame.surface.Surface(surface.get_size())
- brightness = brightness.convert_alpha()
- brightness.fill((255, 255, 255, 50))
- surface.blit(brightness, (0, 0))
-
+ surface.blit(self._soil, (0, 0))
+
for turnip in self._turnips:
turnip.render(surface)
self._lights.render_light(surface)
def _update_toolbar(self, gamestate):
text = ("Turnip Stocks: Seeds: %d. Planted: %d. "
- "Harvested: %d. Destroyed: %d" %
+ "Harvested: %d. Destroyed: %d" %
(self._seeds, len(self._turnips),
self._harvested, gamestate.eaten))
self._toolbar = self._toolbar_font.render(text, True, (255, 255, 255))
""" In the night, the mould attacks. """
import pygame.locals as pgl
-import pygame.surface
import pymunk
from ..events import SceneChangeEvent
from ..utils import debug_timer
from ..loader import loader
+from ..transforms import Overlay
from ..turnip import Turnip
class NightScene(BaseScene):
+
+ DARKNESS = Overlay(colour=(0, 0, 0, 150))
+
def enter(self, gamestate):
self._space = pymunk.Space()
self._obstacles = ObstacleManager(self._space, gamestate)
for turnip_data in gamestate.turnips:
turnip = Turnip(space=self._space, **turnip_data)
self._turnips.append(turnip)
+ self._soil = loader.load_image(
+ "textures", "soil.png", transform=self.DARKNESS)
@debug_timer("night.render")
def render(self, surface, gamestate):
- surface.blit(loader.load_image("textures", "soil.png"), (0, 0))
- darkness = pygame.surface.Surface(surface.get_size())
- darkness = darkness.convert_alpha()
- darkness.fill((0, 0, 0, 150))
- surface.blit(darkness, (0, 0))
-
+ surface.blit(self._soil, (0, 0))
+
self._mould.render(surface)
for turnip in self._turnips[:]:
gamestate.eaten += 1
else:
turnip.render(surface)
+
self._lights.render_light(surface)
self._obstacles.render(surface)
self._lights.render_fittings(surface)