Ignore:
Timestamp:
09/06/13 21:58:15 (8 years ago)
Author:
Stefano Rivera <stefano@…>
Branch:
default
Phase:
public
Rebase:
35303737613634613836383239353338336366613238316631663639633630356133643634333763
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.