Ignore:
Timestamp:
09/04/13 14:53:24 (8 years ago)
Author:
Stefano Rivera <stefano@…>
Branch:
default
Phase:
public
Message:

Overlays belong in render

File:
1 edited

Legend:

Unmodified
Added
Removed
  • nagslang/game_object.py

    r218 r222  
    99from nagslang.resources import resources
    1010from nagslang.events import DoorEvent
    11 from nagslang.widgets.text import LabelWidget
    1211
    1312
     
    8382        body.velocity_func = damping_velocity_func
    8483    return body
    85 
    86 
    87 class Overlay(object):
    88     def set_game_object(self, game_object):
    89         self.game_object = game_object
    90 
    91     def render(self, surface, display_offset):
    92         pass
    93 
    94     def is_visible(self):
    95         return self.game_object.puzzler.get_state()
    96 
    97 
    98 class TextOverlay(Overlay):
    99     def __init__(self, text):
    100         self.text = text
    101         self.widget = LabelWidget((20, 20), self.text)
    102 
    103     def render(self, surface, display_offset):
    104         x, y = 20, 20
    105         if display_offset[0] < 0:
    106             x += abs(display_offset[0])
    107         if display_offset[1] < 0:
    108             y += abs(display_offset[1])
    109         self.widget.rect.topleft = (x, y)
    110         self.widget.draw(surface)
    11184
    11285
     
    189162            render.ImageRenderer(resources.get_image('objects', 'note.png')),
    190163            puzzle.CollidePuzzler(),
    191             TextOverlay(message),
     164            render.TextOverlay(message),
    192165        )
    193166
Note: See TracChangeset for help on using the changeset viewer.