view atc @ 46:ca661c5a267b

Renamed atc.py to just atc
author Josef "Jeff" Sipek <jeffpc@josefsipek.net>
date Fri, 01 Jun 2007 02:08:43 -0400
parents
children d2efdc4ff196
line wrap: on
line source

#!/usr/bin/python

#/*
# * ATC - Air Traffic Controller simulation game
# *
# * Copyright (C) 2004-2007 Josef "Jeff" Sipek <jeffpc@josefsipek.net>
# *
# * This program is free software; you can redistribute it and/or modify
# * it under the terms of the GNU General Public License version 2 as
# * published by the Free Software Foundation.
# *
# * This program is distributed in the hope that it will be useful,
# * but WITHOUT ANY WARRANTY; without even the implied warranty of
# * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# * GNU General Public License for more details.
# */

version = "0.10-pre2"

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");

	# 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()

	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

if (__name__ == '__main__'):
	main()