changeset 49:43a1c4c6955c

Single player mode should take the Game class and modify it s.t. things make sense
author Josef "Jeff" Sipek <jeffpc@josefsipek.net>
date Fri, 01 Jun 2007 03:01:03 -0400
parents 955cd24d7a05
children ade56730daab
files atcgame/game.py atcgame/single.py
diffstat 2 files changed, 32 insertions(+), 41 deletions(-) [+]
line wrap: on
line diff
--- a/atcgame/game.py	Fri Jun 01 02:47:31 2007 -0400
+++ b/atcgame/game.py	Fri Jun 01 03:01:03 2007 -0400
@@ -26,9 +26,6 @@
 
 class Game:
 	def __init__(self, screen):
-		# background music
-		#utils.playmusic("some.mp3");
-
 		self.displays = {
 			"map": 1,
 			"weather": 0,
@@ -64,7 +61,6 @@
 		pygame.display.flip()
 
 		self.planes = []
-		self.planes.append(self.__random_plane())
 		
 		self.weather = weather.Weather()
 	
@@ -76,6 +72,21 @@
 		self.map.cleanup()
 	
 	def __proc_cmd(self):
+		def cmd_plane(cmd):
+			parts = cmd.split(': ')
+			
+			if (parts.__len__()>1):
+				return parts[0]
+			return None
+
+		def cmd_cmd(cmd):
+			parts = cmd.split(': ')
+			
+			if (parts.__len__()>1):
+				return parts[1]
+			return None
+		##
+
 		flno = cmd_plane(self.cmd)
 		com  = cmd_cmd(self.cmd)
 		
@@ -211,15 +222,6 @@
 		
 		return True
 
-	def __random_plane(self):
-		callsign	= "N1499H"
-		flightno	= "Delta 79"
-		squawk	= "1200"
-		type		= "B747"
-		vel		= (20, 20, 20)	# FIXME: use the specs
-
-		return plane.Plane(type=type, callsign=callsign, flightno=flightno, squawk=squawk, vel=vel)
-
 	def run(self):
 		if not self.__proc_events(): return False
 
@@ -261,19 +263,5 @@
 		
 		return True
 
-def cmd_plane(cmd):
-	parts = cmd.split(': ')
-	
-	if (parts.__len__()>1):
-		return parts[0]
-	return None
-
-def cmd_cmd(cmd):
-	parts = cmd.split(': ')
-	
-	if (parts.__len__()>1):
-		return parts[1]
-	return None
-
 if (__name__ == '__main__'):
 	print "Don't do it!"
--- a/atcgame/single.py	Fri Jun 01 02:47:31 2007 -0400
+++ b/atcgame/single.py	Fri Jun 01 03:01:03 2007 -0400
@@ -20,30 +20,33 @@
 import utils
 import plane
 import message
-import game
 
+from game import Game
 from maps import *
 
 def startgame(screen):
 	""" Main fn to run the single player game """
-	g = game.Game(screen)
+	g = Single(screen)
 	
 	while g.run(): pass
 
+class Single(Game):
+	def __init__(self, screen):
+		Game.__init__(self, screen)
 
-def cmd_plane(cmd):
-	parts = cmd.split(': ')
-	
-	if (parts.__len__()>1):
-		return parts[0]
-	return None
+		# background music
+		#utils.playmusic("some.mp3");
+
+		self.planes.append(self.__random_plane())
 
-def cmd_cmd(cmd):
-	parts = cmd.split(': ')
-	
-	if (parts.__len__()>1):
-		return parts[1]
-	return None
+	def __random_plane(self):
+		callsign	= "N1499H"
+		flightno	= "Delta 79"
+		squawk	= "1200"
+		type		= "B747"
+		vel		= (20, 20, 20)	# FIXME: use the specs
+
+		return plane.Plane(type=type, callsign=callsign, flightno=flightno, squawk=squawk, vel=vel)
 
 if (__name__ == '__main__'):
 	print "Don't do it!"