diff options
author | Mateu Batle <mateu.batle@collabora.co.uk> | 2010-10-27 17:40:28 (GMT) |
---|---|---|
committer | Mateu Batle <mateu.batle@collabora.co.uk> | 2010-10-27 17:40:28 (GMT) |
commit | 0018a9e211ebbe74d371339a70edc0d36c4fc99f (patch) | |
tree | ddfd93d0713c615ed70dbf869747b55b94791af8 /usmpgames/infostate.py |
Initial import of game1 and game2 in math quwy
Diffstat (limited to 'usmpgames/infostate.py')
-rwxr-xr-x | usmpgames/infostate.py | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/usmpgames/infostate.py b/usmpgames/infostate.py new file mode 100755 index 0000000..3edfc66 --- /dev/null +++ b/usmpgames/infostate.py @@ -0,0 +1,58 @@ +#!/usr/bin/python +# -*- coding: iso-8859-15 -*- + +import pygame +import jmenu +import sys +import txtlib +from applicationstate import * +from application import * + +class InfoState(ApplicationState): + + def __init__(self, next_state, background = None): + ApplicationState.__init__(self, next_state, background) + self._images = [] + + def clear_all(self): + self._images = [] + + def add_text(self, text, color, pos, rectsize, fontsize, font = None): + textobj = txtlib.Text(rectsize, font, fontsize, text) + textobj.background_color = (255, 255, 255, 0) + textobj.update() + self.add_image( textobj.area, pos ) + + def add_htmltext(self, html_text, color, pos, rectsize, fontsize, font = None): + textobj = txtlib.Text(rectsize, font, fontsize) + textobj.background_color = (255, 255, 255, 0) + textobj.html(html_text) + textobj.update() + self.add_image( textobj.area, pos ) + + def add_image(self, surface, pos): + info = {} + info["surface"] = surface + info["pos"] = pos + self._images.append(info) + + def input(self, ms): + events = pygame.event.get() + if events: + for event in events: + if event.type == pygame.QUIT: + self.set_running( False ) + elif event.type == pygame.KEYDOWN: + if event.key == pygame.K_ESCAPE: + self.set_running( False ) + else: + self.go_to_next_state() + + def render(self, ms): + for info in self._images: + self.screen().blit(info["surface"], info["pos"]) + + def entering_state(self, fromStack): + ApplicationState.entering_state(self, fromStack) + pygame.time.wait(500) + pygame.event.clear() |