Ignore:
Timestamp:
09/07/13 18:20:25 (8 years ago)
Author:
Stefano Rivera <stefano@…>
Branch:
default
Phase:
public
Message:

Ephemeral messages

File:
1 edited

Legend:

Unmodified
Added
Removed
  • nagslang/game_object.py

    r519 r520  
    157157        self.lifetime = 0
    158158        self.physicser = physicser
    159         physicser.set_game_object(self)
    160         self.physicser.add_to_space()
     159        if physicser is not None:
     160            physicser.set_game_object(self)
     161            self.physicser.add_to_space()
    161162        self.renderer = renderer
    162163        renderer.set_game_object(self)
     
    298299        return [("name", "string"), ("position", "coordinates"),
    299300                ("message", "text")]
     301
     302
     303class EphemeralNote(GameObject):
     304    def __init__(self, message, timeout):
     305        super(EphemeralNote, self).__init__(
     306            None,
     307            render.NullRenderer(),
     308            puzzle.YesPuzzler(),
     309            render.TextOverlay(message),
     310        )
     311        self.add_timer('timeout', timeout)
     312        self.start_timer('timeout')
     313
     314    def update(self, dt):
     315        super(EphemeralNote, self).update(dt)
     316        if not self.check_timer('timeout'):
     317            return Result(remove=[self])
    300318
    301319
Note: See TracChangeset for help on using the changeset viewer.