+ self._toolbar_font = loader.load_font(FONTS['sans'], size=20)
+ self._obstacles = ObstacleManager(self._space, gamestate)
+ self._lights = LightManager(self._space, gamestate)
+ self._turnips = []
+ self._seeds = gamestate.seeds
+ self._harvested = gamestate.harvested
+ self._paused = False
+ self._tool = None
+ for turnip_data in gamestate.turnips:
+ turnip = Turnip(space=self._space, **turnip_data)
+ # Turnips grow at dawn
+ seeds = turnip.grow()
+ if seeds:
+ self._seeds += seeds
+ self._harvested += 1
+ else:
+ self._turnips.append(turnip)
+ # Tools
+ self._tools = [
+ ImageButton('32', 'seed.png', name='seed',
+ pos=(50, SCREEN_SIZE[1] - 40)),
+ ImageButton('32', 'spotlight.png', name='blue_spotlight',
+ pos=(100, SCREEN_SIZE[1] - 40),
+ transform=Multiply(colour=(0, 0, 255, 255))),
+ ImageButton('32', 'spotlight.png', name='red_spotlight',
+ pos=(150, SCREEN_SIZE[1] - 40),
+ transform=Multiply(colour=(255, 0, 0, 255))),
+ ImageButton('32', 'default_cursor.png', name='reset tool',
+ 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()
+ gamestate.seeds = self._seeds
+ gamestate.harvested = self._harvested
+ turnip_data = [turnip.serialize() for turnip in self._turnips]
+ gamestate.turnips = turnip_data