Mercurial > nagslang
diff nagslang/screens/area.py @ 276:3153196517fc
Move protagonist to the world
author | Neil Muller <drnlmuller@gmail.com> |
---|---|
date | Thu, 05 Sep 2013 13:09:14 +0200 |
parents | 933c2f9371ca |
children | 56e42c00da25 |
line wrap: on
line diff
--- a/nagslang/screens/area.py Thu Sep 05 12:04:14 2013 +0200 +++ b/nagslang/screens/area.py Thu Sep 05 13:09:14 2013 +0200 @@ -7,7 +7,6 @@ from nagslang.constants import COLLISION_TYPE_PLAYER, CALLBACK_COLLIDERS from nagslang.events import ScreenChange, DoorEvent, FireEvent from nagslang.level import Level -from nagslang.protagonist import Protagonist from nagslang.screens.base import Screen from nagslang.game_object import Bullet from nagslang.sound import sound @@ -73,14 +72,7 @@ self._drawables = Drawables() self.add_walls() self._add_collision_handlers() - if self.protagonist is not None: - # We do things this way to avoid extra pymunk - # juggling to move objects between spaces - old_protagonist = self.protagonist - self.add_protagonist() - self.protagonist.copy_state(old_protagonist) - else: - self.add_protagonist() + self.add_protagonist() self.add_game_objects() sound.play_music("POL-cyber-factory-short.ogg") @@ -123,7 +115,8 @@ self._drawables.add(drawable) def add_protagonist(self): - self.protagonist = Protagonist(self.space, (350, 300)) + self.protagonist = self.world.protagonist + self.protagonist.change_space(self.space) self._drawables.add(self.protagonist) def handle_event(self, ev): @@ -142,7 +135,7 @@ # Go to anther screen self._disable_render = True self.world.rooms += 1 - ScreenChange.post(ev.destination, self.protagonist) + ScreenChange.post(ev.destination) return # else we're teleporting within the screen, and just the # position change is enough