Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/usmpgames/applicationstate.py
diff options
context:
space:
mode:
authorMateu 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)
commit0018a9e211ebbe74d371339a70edc0d36c4fc99f (patch)
treeddfd93d0713c615ed70dbf869747b55b94791af8 /usmpgames/applicationstate.py
Initial import of game1 and game2 in math quwy
Diffstat (limited to 'usmpgames/applicationstate.py')
-rwxr-xr-xusmpgames/applicationstate.py72
1 files changed, 72 insertions, 0 deletions
diff --git a/usmpgames/applicationstate.py b/usmpgames/applicationstate.py
new file mode 100755
index 0000000..fc5ca72
--- /dev/null
+++ b/usmpgames/applicationstate.py
@@ -0,0 +1,72 @@
+#!/usr/bin/python
+# -*- coding: iso-8859-15 -*-
+
+import pygame
+from application import *
+
+class ApplicationState():
+
+ def __init__(self, next_state = None, background = None):
+ self._running = True
+ self._screen = None
+ self._next_state = next_state
+ self._background = background
+
+ def input(self, ms):
+ pass
+
+ def simulation(self, ms):
+ pass
+
+ def pre_render(self, ms):
+ if self.background() is not None and self.screen() is not None :
+ self.screen().blit( self.background(), (0, 0) )
+
+ def render(self, ms):
+ pass
+
+ def post_render(self, ms):
+ pygame.display.flip()
+
+ def set_background(self, background):
+ self._background = background
+
+ def background(self):
+ if self._background is not None:
+ return self._background
+ return None
+
+ def set_running(self, newValue):
+ self._running = newValue
+
+ def running(self):
+ return self._running
+
+ def set_screen(self, screen):
+ self._screen = screen
+
+ def screen(self):
+ return self._screen
+
+ def loop(self, ms):
+ self.input(ms)
+ self.simulation(ms)
+ self.pre_render(ms)
+ self.render(ms)
+ self.post_render(ms)
+
+ def entering_state(self, fromStack):
+ print "Entering state ", self
+ self.set_running(True)
+ pass
+
+ def exiting_state(self, toStack):
+ print "Exiting state ", self
+ pass
+
+ def go_to_next_state(self):
+ Application.instance().change_state( self._next_state )
+
+ def next_state(self):
+ return self._next_state
+