diff demos/shooter/scripts/scene.py @ 455:e686b82d93d0

Added the ability to pause the game. Added the main menu.
author prock@33b003aa-7bff-0310-803a-e67f0ece8222
date Wed, 07 Apr 2010 19:37:42 +0000
parents bd7e8f708adf
children 597b066d5ccb
line wrap: on
line diff
--- a/demos/shooter/scripts/scene.py	Tue Apr 06 21:25:10 2010 +0000
+++ b/demos/shooter/scripts/scene.py	Wed Apr 07 19:37:42 2010 +0000
@@ -62,6 +62,9 @@
 		
 		self._xscale = self._layer.getCellGrid().getXScale()
 		self._yscale = self._layer.getCellGrid().getYScale()
+		
+		self._paused = False
+		self._timemod = 0
 
 	def initScene(self, mapobj):
 		self._player = Player(self, 'player')
@@ -97,6 +100,14 @@
 		#and finally add the player to the scene
 		self.addObjectToScene(self._player)
 
+	def pause(self, time):
+		self._pausedtime = time
+		self._paused = True
+		
+	def unpause(self, time):
+		self._timemod += time - self._pausedtime
+		self._paused = False
+
 	def getObjectsInNode(self, nodeindex):
 		return self._nodes[nodeindex].instances
 
@@ -139,9 +150,9 @@
 		self._camera.setLocation(self._player.location)
 		
 	def update(self, time, keystate):
-		timedelta = time - self._time
+		timedelta = (time - self._timemod) - self._time
 		self._timedelta = timedelta
-		self._time = time
+		self._time = time - self._timemod
 		
 		self._keystate = keystate
 		
@@ -229,7 +240,10 @@
 	
 	def _getTimeDelta(self):
 		return self._timedelta
-
+		
+	def _getPaused(self):
+		return self._paused
+		
 	player = property(_getPlayer)
 	keystate = property(_getKeyState)
 	camera = property(_getCamera)
@@ -237,4 +251,4 @@
 	model = property(_getModel)
 	time = property(_getTime)
 	timedelta = property(_getTimeDelta)
-		
+	paused = property(_getPaused)