Ignore:
Timestamp:
09/05/13 14:10:57 (8 years ago)
Author:
Jeremy Thurgood <firxen@…>
Branch:
default
Phase:
public
Message:

Toggle switch, sans art.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • nagslang/game_object.py

    r281 r282  
    308308
    309309
     310class ToggleSwitch(GameObject):
     311    zorder = ZORDER_LOW
     312
     313    def __init__(self, space, position):
     314        body = make_body(None, None, position)
     315        self.shape = pymunk.Circle(body, 20)
     316        self.shape.sensor = True
     317        self.toggle_on = False
     318        super(ToggleSwitch, self).__init__(
     319            SingleShapePhysicser(space, self.shape),
     320            render.ShapeStateRenderer(),
     321            puzzle.ParentAttrPuzzler('toggle_on'),
     322            interactible=environment.Interactible(
     323                environment.Action(self._toggle)),
     324        )
     325
     326    def _toggle(self, protagonist):
     327        self.toggle_on = not self.toggle_on
     328
     329    @classmethod
     330    def requires(cls):
     331        return [("name", "string"), ("position", "coordinates")]
     332
     333
    310334class Bullet(GameObject):
    311335    def __init__(self, space, position, impulse):
Note: See TracChangeset for help on using the changeset viewer.