Changeset 277:56e42c00da25 for nagslang


Ignore:
Timestamp:
Sep 5, 2013, 11:15:31 AM (7 years ago)
Author:
Neil Muller <drnlmuller@…>
Branch:
default
Message:

Protagonist and enemies should see the world

Location:
nagslang
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • nagslang/enemies.py

    r265 r277  
    2323    """A base class for mobile enemies"""
    2424
    25     def __init__(self, space, position):
     25    def __init__(self, space, world, position):
    2626        self._setup_physics(space, position)
    2727        self._setup_renderer()
     
    3030            self._physicser, self.renderer)
    3131        self.zorder = ZORDER_MID
     32        self.world = world
    3233
    3334    def _get_image(self, name, *transforms):
     
    5152    is_moving = True  # Always walking.
    5253
    53     def __init__(self, space, position, end_position):
     54    def __init__(self, space, world, position, end_position):
    5455        # An enemy that patrols between the two points
    55         super(PatrollingAlien, self).__init__(space, position)
     56        super(PatrollingAlien, self).__init__(space, world, position)
    5657        self._start_pos = position
    5758        self._end_pos = end_position
  • nagslang/level.py

    r274 r277  
    2323class Level(object):
    2424
    25     def __init__(self, name):
     25    def __init__(self, name, world):
    2626        self.name = name
    2727        # defaults
     
    3030        self.polygons = {}
    3131        self.lines = []
     32        self.world = world
    3233        self.basetile = 'tiles/floor.png'
    3334        self._tile_image = None
     
    101102        cls = getattr(enemies, classname)
    102103        if issubclass(cls, go.GameObject):
    103             gobj = cls(space, *args)
     104            gobj = cls(space, self.world, *args)
    104105            self.drawables.append(gobj)
    105106        else:
  • nagslang/protagonist.py

    r276 r277  
    4343    WOLF_FORM = 'wolf'
    4444
    45     def __init__(self, space, position):
     45    def __init__(self, space, world, position):
    4646        physicser = self._make_physics(space, position)
    4747        renderer = self._make_renderer()
     
    5050        self.angle = 0
    5151        self.is_moving = False
     52        self.world = world
    5253
    5354        super(Protagonist, self).__init__(physicser, renderer)
  • nagslang/screens/area.py

    r276 r277  
    6868        self._disable_render = False  # Avoid redrawing on scene changes
    6969        self.keys = ControlKeys()
    70         self._level = Level(self.name)
     70        self._level = Level(self.name, self.world)
    7171        self._level.load(self.space)
    7272        self._drawables = Drawables()
  • nagslang/world.py

    r276 r277  
    2222        self.kills = 0
    2323        self.rooms = 0
    24         self.protagonist = Protagonist(pymunk.Space(), (350, 300))
     24        self.protagonist = Protagonist(pymunk.Space(), self, (350, 300))
    2525
    2626    def _save_location(self):
Note: See TracChangeset for help on using the changeset viewer.