diff atc @ 47:d2efdc4ff196

Initial reorganization of the code
author Josef "Jeff" Sipek <jeffpc@josefsipek.net>
date Fri, 01 Jun 2007 02:32:48 -0400
parents ca661c5a267b
children
line wrap: on
line diff
--- a/atc	Fri Jun 01 02:08:43 2007 -0400
+++ b/atc	Fri Jun 01 02:32:48 2007 -0400
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/env python
 
 #/*
 # * ATC - Air Traffic Controller simulation game
@@ -15,84 +15,13 @@
 # * GNU General Public License for more details.
 # */
 
-version = "0.10-pre2"
+import os, sys
 
-try:
-	import sys
-	import threading
-	import pygame
-	
-	import atc_config
-	
-	import atc_colors
-	import atc_utils
-	import atc_plane
-	import atc_message
-	
-	import atc_single
-except ImportError, err:
-	print "Couldn't load module %s" % (err)
-	sys.exit()
-
-size = width, height = 1024, 768
-
-def main():
-	""" Main fn to run the main thread """
-	
-	# Init
-	pygame.init()
-	screen = pygame.display.set_mode(size)
-	pygame.display.set_caption('Air Traffic Controller (' + version + ')')
-	
-	# background music
-	try:
-		pygame.mixer.init()
-	except pygame.error:
-		print "Could not init sound"
-		sys.exit(1)
-	#atc_utils.playmusic("some.mp3");
+basedir = os.path.dirname(sys.argv[0])
 
-	# Set background
-	background = pygame.Surface(screen.get_size()).convert()
-	background.fill(atc_colors.black)
-	
-	(splash_image, splash_rect) = atc_utils.load_png('data/image/splash.png')
-	background.blit(splash_image, (0, 0))
-
-	#blit!
-	screen.blit(background, (0, 0))
-	pygame.display.flip()
+import atcgame.mainmenu
 
-	optsel = 0
-	menustr = ('single', 'multi', 'quit')
-	
-	while 1:
-		event = pygame.event.wait()
-		if event.type == pygame.QUIT:
-			sys.exit()
-		if event.type == pygame.KEYDOWN:
-			if event.key == pygame.K_UP:
-				optsel = (optsel + 2) % 3
-			if event.key == pygame.K_DOWN:
-				optsel = (optsel + 1) % 3
-			if event.key == pygame.K_RETURN:
-				optsel = optsel | 0x10
-			if optsel == 0x12:
-				sys.exit()
-		
-		screen.blit(background, (0, 0))
-		
-		(menu_img, menu_rect) = atc_utils.load_png('data/image/menu_' + menustr[optsel & 3] + '.png')
-		screen.blit(menu_img, ((width - 334)/2.0, (height - 225)/2.0))
-		
-		pygame.display.flip()
-		
-		if (optsel & 0x10):
-			optsel = optsel & 3
-			if (optsel == 0): # single player
-				atc_single.startgame(screen)
-			if (optsel == 1): # multi player
-				pass # FIXME: implement
+# a hack to make things run from current dir without having to install
+sys.path.insert(0, os.path.join(basedir,"atcgame"))
 
-if (__name__ == '__main__'):
-	main()
+atcgame.mainmenu.main(os.path.join(basedir,"data"))