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/render.py

    r221 r222  
    55
    66from nagslang.options import options
     7from nagslang.widgets.text import LabelWidget
    78
    89
     
    171172        self.game_object.get_shape().color = color
    172173        super(ShapeStateRenderer, self).render(surface)
     174
     175
     176class Overlay(object):
     177    def set_game_object(self, game_object):
     178        self.game_object = game_object
     179
     180    def render(self, surface, display_offset):
     181        pass
     182
     183    def is_visible(self):
     184        return self.game_object.puzzler.get_state()
     185
     186
     187class TextOverlay(Overlay):
     188    def __init__(self, text):
     189        self.text = text
     190        self.widget = LabelWidget((20, 20), self.text)
     191
     192    def render(self, surface, display_offset):
     193        x, y = 20, 20
     194        if display_offset[0] < 0:
     195            x += abs(display_offset[0])
     196        if display_offset[1] < 0:
     197            y += abs(display_offset[1])
     198        self.widget.rect.topleft = (x, y)
     199        self.widget.draw(surface)
Note: See TracChangeset for help on using the changeset viewer.