Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin Hockey <Blitzkev@gmail.com>2010-08-05 16:59:37 (GMT)
committer Kevin Hockey <Blitzkev@gmail.com>2010-08-05 16:59:37 (GMT)
commit0527d25fb0c0a3c22c6b10d1bf85b72c3947fd90 (patch)
tree4ea4ee66b33e7cc93cfdd4985a171bab5a1db041
parented258092599598639eb8c75b73529a29b13a70a6 (diff)
gameengine that defaults to old version for backwards compat.
-rw-r--r--MAFH2/fortuneengine/GameEngine.py51
1 files changed, 34 insertions, 17 deletions
diff --git a/MAFH2/fortuneengine/GameEngine.py b/MAFH2/fortuneengine/GameEngine.py
index 180e78c..8d9a713 100644
--- a/MAFH2/fortuneengine/GameEngine.py
+++ b/MAFH2/fortuneengine/GameEngine.py
@@ -29,7 +29,7 @@ class GameEngine(object):
"""
instance = None
- def __init__(self, width=1200, height=900, always_draw=False, fps_cap=15):
+ def __init__(self, width=1200, height=900, always_draw=False, fps_cap=15, version=False):
"""
Constructor for the game engine.
@@ -45,6 +45,7 @@ class GameEngine(object):
GameEngine.instance = self
pygame.init()
pygame.mouse.set_visible(False)
+ self.__version = version #true is new, false is old
# Window Settings
self.width = width
@@ -54,6 +55,7 @@ class GameEngine(object):
self.__fps = DrawableFontObject("", pygame.font.Font(None, 17))
self.__fps.setPosition(0,0)
self.__scene = Scene(self.__fps)
+
# Engine Internal Variables
self.__fps_cap = fps_cap
@@ -67,7 +69,7 @@ class GameEngine(object):
self.__event_cb = []
self.__draw_lst = []
self.__object_hold = {}
- self.__dirtyList=[]
+
# Game Timers
self.__active_event_timers = []
@@ -205,23 +207,38 @@ class GameEngine(object):
# If console is active, we want to draw console, pausing
# game drawing (events are still being fired, just no
# draw updates.
- if self.console.active:
- self.console.draw()
- pygame.display.flip()
-
+ if self.__version:
+ if self.console.active:
+ self.console.draw()
+ pygame.display.flip()
+ else:
+ for fnc in self.__draw_lst:
+ start = time()
+ fnc()
+ self.__draw_time[str(fnc)] += time() - start
+ self.__draw_calls[str(fnc)] += 1
+ # Print Frame Rate
+ if self.__showfps:
+ self.__fps.changeText('FPS: %d' % self.clock.get_fps(), (255,255,255))
+ else:
+ self.__fps.changeText('')
+ self.__scene.update(tick_time)
+ pygame.display.update(self.__scene.draw(screen))
else:
- for fnc in self.__draw_lst:
- start = time()
- fnc(screen, tick_time)
- self.__draw_time[str(fnc)] += time() - start
- self.__draw_calls[str(fnc)] += 1
- # Print Frame Rate
- if self.__showfps:
- self.__fps.changeText('FPS: %d' % self.clock.get_fps(), (255,255,255))
+ if self.console.active:
+ self.console.draw()
+ pygame.display.flip()
else:
- self.__fps.changeText('')
- self.__scene.update(tick_time)
- pygame.display.update(self.__scene.draw(screen))
+ for fnc in self.__draw_lst:
+ start = time()
+ fnc(screen, tick_time)
+ self.__draw_time[str(fnc)] += time() - start
+ self.__draw_calls[str(fnc)] += 1
+ # Print Frame Rate
+ if self.__showfps:
+ text = self.__font.render('FPS: %d' % self.clock.get_fps(),False, (255, 255, 255), (159, 182, 205))
+ screen.blit(text, (0, 0))
+ pygame.display.flip()
def _event_loop(self):
"""