self._text = None
self._infobar = None
- def render(self, surface):
- if self._infobar is None:
- self._update_infobar()
+ def render(self, surface, gamestate):
+ self._update(gamestate)
surface.blit(self._infobar, self.pos, None)
def _update_infobar(self):
self._infobar.fill((0, 0, 0, 64))
self._infobar.blit(text_img, (5, 3), None)
- def update(self, gamestate):
+ def _update(self, gamestate):
options = {
"gamestate": gamestate, "battery": self.battery,
"scene": self.scene, "time_of_day": self.time_of_day,
text = self.template.format(**options)
if text != self._text:
self._text = text
- self._infobar = None
+ self._update_infobar()
# Tools
self._light_toolbar = []
self._tools = self.create_tools(gamestate)
- self._infobar.update(gamestate)
# Background
self._soil = loader.load_image(
"textures", "soil.png", transform=self.BRIGHTNESS)
self._lights.render_light(surface)
self._obstacles.render(surface)
self._lights.render_fittings(surface)
- self._infobar.render(surface)
+ self._infobar.render(surface, gamestate)
for tool in self._tools:
tool.render(surface)
for light_tool in self._light_toolbar:
turnip = Turnip(age=0, pos=pos, space=self._space)
self._turnips.append(turnip)
gamestate.seeds -= 1
- self._infobar.update(gamestate)
except TurnipInvalidPosition:
# TODO: Add error sound or something
pass
if self._lights.nearest(pos, max_distance=25):
return
gamestate.seeds -= cost
- self._infobar.update(gamestate)
cfg["position"] = pos
cfg["colours"] = colours
gamestate.station["lights"].append(cfg)