}
def __init__(self, colour, position):
- self.on = True
- self.body = pymunk.Body(0, 0, pymunk.body.Body.STATIC)
- self.fitting = pymunk.Circle(self.body, 5.0)
self.colour = colour
self.position = pymunk.Vec2d(position)
+ self.on = True
+ self.body = pymunk.Body(0, 0, pymunk.body.Body.STATIC)
+ self.fitting = pymunk.Circle(self.body, 10.0, self.position)
+ self.body.light = self
@classmethod
def load(cls, config):
surface.blit(subsurface, (0, 0), None)
def render_fittings(self, surface):
- centre = self.position + self.fitting.offset
pygame.draw.circle(
surface, (255, 255, 0),
- pymunk.pygame_util.to_pygame(centre, surface),
+ pymunk.pygame_util.to_pygame(self.fitting.offset, surface),
int(self.fitting.radius))
light.render_fittings(surface)
def left_click(self, surfpos):
- print "LEFT"
pos = pymunk.pygame_util.from_pygame(
surfpos, pygame.display.get_surface())
- print surfpos, pos
- print self._space.point_query(pos, 1.0, CLICK_FILTER)
+ point_info = self._space.point_query_nearest(pos, 1.0, CLICK_FILTER)
+ if point_info is not None:
+ point_info.shape.body.light.toggle()
def right_click(self, pos):
pass