Changeset 37:4140780c21bc


Ignore:
Timestamp:
Sep 1, 2013, 3:06:06 PM (7 years ago)
Author:
Simon Cross <hodgestar@…>
Branch:
default
rebase_source:
de140e406dbfc24d9d4b25bc69b9fb6586a92774
Message:

Give screens a name and a world.

Location:
nagslang
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • nagslang/engine.py

    r25 r37  
    2525        if self._current_screen is not None:
    2626            self._current_screen.teardown()
    27         self._current_screen = self._screens[new_screen]()
    28         self._current_screen.setup(self._world)
     27        screen_cls = self._screens[new_screen]
     28        self._current_screen = screen_cls(new_screen, self._world)
     29        self._current_screen.setup()
    2930
    3031    def run(self):
  • nagslang/screens/area.py

    r35 r37  
    2828class AreaScreen(Screen):
    2929
    30     def setup(self, world):
     30    def setup(self):
    3131        self.keys = ControlKeys()
    32         self.add_walls(world)
    33         self.add_protagonist(world)
     32        self.add_walls()
     33        self.add_protagonist()
    3434
    35     def add_walls(self, world):
     35    def add_walls(self):
    3636        self.walls = []
    3737        body = pymunk.Body()
     
    4444        self.space.add(*self.walls)
    4545
    46     def add_protagonist(self, world):
     46    def add_protagonist(self):
    4747        self.protagonist_body = pymunk.Body(100, 1000)
    4848        self.protagonist_body.position = (400, 300)
  • nagslang/screens/base.py

    r34 r37  
    77class Screen(object):
    88
    9     def __init__(self):
     9    def __init__(self, name, world):
     10        self.name = name
     11        self.world = world
    1012        self.space = pymunk.Space()
    1113
    12     def setup(self, world):
     14    def setup(self):
    1315        """Perform setup based on the world state."""
    1416        pass
Note: See TracChangeset for help on using the changeset viewer.