X-Git-Url: https://git.ctpug.org.za/?a=blobdiff_plain;f=tabakrolletjie%2Fscenes%2Fday.py;h=3e001eef4e11ed83e0bd9b04d486f0ede52de375;hb=051f941fcf7095e5a6b93f538f8a9bb867067ca7;hp=933f16bad399df9dd430b3737e0b5f2ee21bd5e9;hpb=2c844664ed953dd3e6941f741ea7057a8f34e218;p=tabakrolletjie.git diff --git a/tabakrolletjie/scenes/day.py b/tabakrolletjie/scenes/day.py index 933f16b..3e001ee 100644 --- a/tabakrolletjie/scenes/day.py +++ b/tabakrolletjie/scenes/day.py @@ -116,14 +116,19 @@ class DayScene(BaseScene): # TODO: Add error sound or something pass - def _update_light_angle(self, pos): + def _update_light_angle(self, pos, gamestate): # Update the angle of the given light pos = pymunk.pygame_util.to_pygame(pos, pygame.display.get_surface()) distance = pos - self._dragging.position angle = math.atan2(distance[1], distance[0]) # Set light angle to this position self._dragging.ray_manager.direction = math.degrees(angle) - # TODO: Update gamestate with new angle + # Hackily update gamestate with new angle + for light_cfg in gamestate.station["lights"]: + light_pos = pymunk.Vec2d(light_cfg["position"]) + if light_pos.get_dist_sqrd(self._dragging.position) < 5.0: + light_cfg["direction"] = math.degrees(angle) + break def _place_spotlight(self, gamestate, colour, ev): if self._seeds > 5: @@ -136,7 +141,7 @@ class DayScene(BaseScene): self._update_toolbar(gamestate) cfg = { "type": "spotlight", - "colour": colour, + "colours": [colour], "position": pos, "direction": 45, "spread": 90, @@ -157,7 +162,7 @@ class DayScene(BaseScene): self._update_toolbar(gamestate) cfg = { "type": "lamp", - "colour": colour, + "colours": [colour], "position": pos, "intensity": 0.5, } @@ -218,7 +223,7 @@ class DayScene(BaseScene): print self._lights.lit_by(ev.pos, surfpos=True) elif ev.button == 3: light = self._lights.nearest(ev.pos, surfpos=True, - max_distance=5.0) + max_distance=20.0) if light: # Start drag to rotate light self._dragging = light @@ -229,7 +234,7 @@ class DayScene(BaseScene): elif ev.type == pgl.MOUSEMOTION: if self._dragging: # Calculate angle between current position and mouse pos - self._update_light_angle(ev.pos) + self._update_light_angle(ev.pos, gamestate) elif ev.type == pgl.MOUSEBUTTONUP: self._dragging = None