+ 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)
+ # 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
+