view atc.py @ 22:a6f6d5d822be

Created config file Added config option to display different plane info label styles committer: Jeff <jeffpc@batlh.(none)> 1121704859 -0400
author Jeff <jeffpc@batlh.(none)>
date Mon, 18 Jul 2005 16:40:59 -0400
parents c28ae64fcb6e
children 6854dc3a8273
line wrap: on
line source

#!/usr/bin/python

#/*
# * ATC - Air Traffic Controller simulation game
# *
# * Copyright (C) 2004, 2005 Josef "Jeff" Sipek <jeffpc@optonline.net>
# *
# * This program is free software; you can redistribute it and/or modify
# * it under the terms of the GNU General Public License as published by
# * the Free Software Foundation; either version 2 of the License, or
# * (at your option) any later version.
# *
# * 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.
# *
# * You should have received a copy of the GNU General Public License
# * along with this program; if not, write to the Free Software
# * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
# *
# * @(#) %M% %I% %E% %U%
# */

version = "0.10-pre1"

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
	pygame.mixer.init()
	#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.single(screen)
			if (optsel == 1): # multi player
				pass # FIXME: implement

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