Changeset 140:f36a7075d9a0


Ignore:
Timestamp:
Sep 2, 2013, 4:31:03 PM (7 years ago)
Author:
Jeremy Thurgood <firxen@…>
Branch:
default
rebase_source:
c9665893ba6e127e74b9f3d37f1852bf1e98b0a8
Message:

Two switch puzzle!

Location:
nagslang
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • nagslang/game_object.py

    r133 r140  
    5252    def get_state(self):
    5353        return self.glue.get_state_of(self._state_source)
     54
     55
     56class StateLogicalAndPuzzler(Puzzler):
     57    def __init__(self, *state_sources):
     58        self._state_sources = state_sources
     59
     60    def get_state(self):
     61        for state_source in self._state_sources:
     62            if not self.glue.get_state_of(state_source):
     63                return False
     64        return True
    5465
    5566
  • nagslang/screens/area.py

    r133 r140  
    77from nagslang.constants import ZORDER_HIGH
    88from nagslang.events import ScreenChange
    9 from nagslang.game_object import FloorSwitch, FloorLight, PuzzleGlue, Box
     9from nagslang.game_object import (
     10    FloorSwitch, FloorLight, PuzzleGlue, Box, StateLogicalAndPuzzler)
    1011from nagslang.level import Level
    1112from nagslang.protagonist import Protagonist
     
    7879        glue = PuzzleGlue()
    7980        switch = FloorSwitch(self.space, (300, 400))
     81        switch2 = FloorSwitch(self.space, (300, 600))
    8082        light = FloorLight(self.space, (300, 500), 'switch')
    81         light2 = FloorLight(self.space, (250, 500), 'switch')
     83        light2 = FloorLight(self.space, (250, 500), 'both_switches')
    8284        light2.zorder = ZORDER_HIGH
    8385        glue.add_component('switch', switch.puzzler)
     86        glue.add_component('switch2', switch2.puzzler)
    8487        glue.add_component('light', light.puzzler)
    8588        glue.add_component('light2', light2.puzzler)
     89        glue.add_component(
     90            'both_switches', StateLogicalAndPuzzler('switch', 'switch2'))
    8691        self._drawables.add(switch)
     92        self._drawables.add(switch2)
    8793        self._drawables.add(light)
    8894        self._drawables.add(light2)
Note: See TracChangeset for help on using the changeset viewer.