Ignore:
Timestamp:
Sep 6, 2013, 9:58:15 PM (7 years ago)
Author:
Stefano Rivera <stefano@…>
Branch:
default
rebase_source:
5077a64a868295383cfa281f1f69c605a3d6437c
Message:

Use a result object to get new drawables back to the area

File:
1 edited

Legend:

Unmodified
Added
Removed
  • nagslang/game_object.py

    r384 r385  
    1414from nagslang.resources import resources
    1515from nagslang.events import DoorEvent
     16
     17
     18class Result(object):
     19    '''
     20    Return from an update() function, to add new objects to the world, and/or
     21    remove old objects.
     22    '''
     23    def __init__(self, add=(), remove=()):
     24        self.add = add
     25        self.remove = remove
    1626
    1727
     
    126136        if interactible is not None:
    127137            self.interactible.set_game_object(self)
    128         self.remove = False  # If true, will be removed from drawables
    129138        self._timers = {}
    130139        self._active_timers = {}
     
    483492                shape.physicser.game_object.hit(self)
    484493            self.physicser.remove_from_space()
    485             self.remove = True
    486             break
     494            return Result(remove=[self])
    487495
    488496
     
    508516        if self.lifetime > 0.1:
    509517            self.physicser.remove_from_space()
    510             self.remove = True
     518            return Result(remove=[self])
    511519
    512520
Note: See TracChangeset for help on using the changeset viewer.