Mercurial > nagslang
view nagslang/events.py @ 112:c28f2fc2bb05
Test with dump_s and load_s
author | Stefano Rivera <stefano@rivera.za.net> |
---|---|
date | Mon, 02 Sep 2013 14:50:30 +0200 |
parents | 347667c941de |
children | 026297a03963 |
line wrap: on
line source
"""Events to post.""" import pygame class Event(object): TYPE = None @classmethod def post(cls, **data): ev = pygame.event.Event(cls.TYPE, **data) pygame.event.post(ev) @classmethod def matches(cls, ev): return ev.type == cls.TYPE class QuitEvent(Event): TYPE = pygame.locals.QUIT class UserEvent(Event): TYPE = pygame.locals.USEREVENT @classmethod def post(cls, **data): super(UserEvent, cls).post(user_type=cls.__name__, **data) @classmethod def matches(cls, ev): return (super(UserEvent, cls).matches(ev) and ev.user_type == cls.__name__) class ScreenChange(UserEvent): @classmethod def post(cls, new_screen): super(ScreenChange, cls).post(screen=new_screen)