Changeset 505:80c452f348dc for nagslang


Ignore:
Timestamp:
Sep 7, 2013, 4:38:40 PM (7 years ago)
Author:
Stefano Rivera <stefano@…>
Branch:
default
Message:

Rearrange progress saving, to happen on room entrance

Location:
nagslang
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • nagslang/engine.py

    r448 r505  
    2626        starting_area = Level.game_starting_point()[0]
    2727
    28         self._world.load()
    2928        if options.point:
    3029            x, y = options.point.split(',')
  • nagslang/screens/area.py

    r503 r505  
    8686        self._level = Level(self.name, self.world)
    8787        self._level.load(self.space)
    88         self.game_starting_point = Level.game_starting_point()
    8988        self._drawables = Drawables()
    9089        self.add_walls()
     
    9291        self.add_protagonist()
    9392        self.add_game_objects()
     93        self.save_progress()
    9494        sound.play_music("POL-cyber-factory-short.ogg")
    9595
     
    159159        self.protagonist = self.world.protagonist
    160160        self.protagonist.change_space(self.space)
     161        self.world.rooms += 1
    161162        self._drawables.add(self.protagonist)
     163
     164    def save_progress(self):
     165        if self.name == Level.game_starting_point()[0]:
     166            return
     167        self.world.level = (self.name, (self.protagonist.physicser.position.x,
     168                                        self.protagonist.physicser.position.y))
     169        self.world.save()
    162170
    163171    def handle_event(self, ev):
     
    181189                # Go to anther screen
    182190                self._disable_render = True
    183                 self.world.rooms += 1
    184                 self.world.level = (ev.destination, ev.dest_pos)
    185                 self.world.save()
    186191                ScreenChange.post(ev.destination)
    187192                return
  • nagslang/world.py

    r437 r505  
    1616
    1717    def __init__(self):
     18        self.__dict__['protagonist'] = Protagonist(
     19            pymunk.Space(), self, Level.game_starting_point()[1])
    1820        self.reset()
    1921
     
    2931            'inventory': set(),
    3032        }
    31         self.__dict__['protagonist'] = Protagonist(
    32             pymunk.Space(), self, self.level[1])
     33        self.save()
    3334
    3435    def __getattr__(self, name):
  • nagslang/yamlish.py

    r380 r505  
    4848                f = getattr(self, '_dump_%s' % type_.__name__)
    4949                return f(data)
    50         raise NotImplementedError()
     50        raise NotImplementedError('Type: %s' % type(data))
    5151
    5252    def _dump_list_block(self, data, indent):
Note: See TracChangeset for help on using the changeset viewer.