from .base import Scene, ChangeSceneEvent
+TOOLBAR_LEFT_X = WIDTH * 3 // 4
+TOOLBAR_TOP_Y = 0
+TOOLBAR_MID_Y = HEIGHT * 1 // 2
+BUTTON_INSET = (20, 20)
+
+
+def inset_button(pos, dx, dy):
+ return (
+ pos[0] + dx * BUTTON_INSET[0],
+ pos[1] + dy * BUTTON_INSET[1])
+
+
class RoachesScene(Scene):
""" Roach management scene. """
self._roach_actors = {}
self._roaches = self.actors.add_layer("roaches", level=10)
self._pads = self.actors.add_layer("pads", level=5)
+ self._buttons = self.actors.add_layer("buttons", level=6)
+ self._init_bg()
self._init_pads()
+ self._init_buttons()
+
+ def _init_bg(self):
+ self.actors.default.add(Actor("vehicles/walking/background"))
def _init_pads(self):
self._roach_pad = self._pads.add(
- Actor("roach_management/roach_pad"))
- self._roach_pad.pos = (WIDTH * (7/8), HEIGHT * (1/4))
+ Actor("roach_management/roach_pad", anchor=("left", "bottom")))
+ self._roach_pad.pos = (TOOLBAR_LEFT_X, TOOLBAR_MID_Y)
self._inventory_pad = self._pads.add(
- Actor("roach_management/inventory_pad"))
- self._inventory_pad.pos = (WIDTH * (7/8), HEIGHT * (3/4))
+ Actor("roach_management/inventory_pad", anchor=("left", "top")))
+ self._inventory_pad.pos = (TOOLBAR_LEFT_X, TOOLBAR_MID_Y)
+
+ def _init_buttons(self):
+ self._roach_left = self._buttons.add(
+ Actor("roach_management/left_button", anchor=("left", "bottom")))
+ self._roach_left.pos = inset_button(
+ self._roach_pad.bottomleft, 1, -1)
+
+ self._roach_right = self._buttons.add(
+ Actor("roach_management/right_button", anchor=("right", "bottom")))
+ self._roach_right.pos = inset_button(
+ self._roach_pad.bottomright, -1, -1)
+
+ self._inventory_left = self._buttons.add(
+ Actor("roach_management/left_button", anchor=("left", "bottom")))
+ self._inventory_left.pos = inset_button(
+ self._inventory_pad.bottomleft, 1, -1)
+
+ self._inventory_right = self._buttons.add(
+ Actor("roach_management/right_button", anchor=("right", "bottom")))
+ self._inventory_right.pos = inset_button(
+ self._inventory_pad.bottomright, -1, -1)
+
+ self._road_eject = self._buttons.add(
+ Actor("roach_management/eject_button", anchor=("right", "top")))
+ self._road_eject.pos = inset_button(
+ (TOOLBAR_LEFT_X, TOOLBAR_TOP_Y), -1, 1)
def update(self, world, dt):
for i, roach in enumerate(world.roaches):