diff demos/shooter/scripts/world.py @ 467:4d0aa75a82f1

Added damage so some enemies take more than one hit to destroy. Added the boss at the end of the level. For some reason the high score dialog box that appears after the level is completed causes a crash. Still looking into this one.
author prock@33b003aa-7bff-0310-803a-e67f0ece8222
date Wed, 14 Apr 2010 16:22:36 +0000
parents 4e58dab2fcdc
children ebbb420a90b9
line wrap: on
line diff
--- a/demos/shooter/scripts/world.py	Tue Apr 13 21:30:51 2010 +0000
+++ b/demos/shooter/scripts/world.py	Wed Apr 14 16:22:36 2010 +0000
@@ -79,6 +79,8 @@
 		
 		self._genericrenderer = None
 		
+		self._sceneended = False
+		
 	def showMainMenu(self):
 		if self.scene:
 			self._paused = True
@@ -105,7 +107,12 @@
 		self.map = None
 		
 		self.cameras = {}
-		self.scene = None
+		
+		if self.scene:
+			self.scene.destroyScene()
+			self.scene = None
+			
+		self._sceneended = False
 
 	def loadLevel(self, filename):
 		"""
@@ -193,9 +200,28 @@
 			dlg = pychan.loadXML('gui/highscoredialog.xml')
 			dlg.execute({ 'okay' : "Yay!" })
 			name = dlg.findChild(name='name').text
+			
 			self._highscores.addHighScore(HighScore(name, self.scene.player.score))
 			self._highscores.show()
+	
+	def endLevel(self):
+		#there is only one level so do the high score display
+		self._paused = True
+
+		if self._highscores.isHighScore(self.scene.player.score):
+			score = self.scene.player.score
+			#self.reset()
 			
+			dlg = pychan.loadXML('gui/highscoredialog.xml')
+			dlg.execute({ 'okay' : "Yay!" })
+			name = dlg.findChild(name='name').text
+			
+			#self._highscores.addHighScore(HighScore(name, score))
+			#self._highscores.show()
+			
+		self._sceneended = True
+
+
 
 	def newGame(self):
 		self.loadLevel("maps/shooter_map1.xml")
@@ -275,6 +301,10 @@
 		Called every frame.
 		"""
 	
+		if self._sceneended:
+			self.reset()
+			self.showMainMenu()	
+	
 		if self._genericrenderer:
 			self._genericrenderer.removeAll("quads")
 
@@ -320,4 +350,5 @@
 			if not self.scene.paused:
 				self.scene.pause(self.timemanager.getTime() - self._starttime)
 		
+		
 		self.pump_ctr += 1