Mercurial > atc
comparison 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 |
comparison
equal
deleted
inserted
replaced
46:ca661c5a267b | 47:d2efdc4ff196 |
---|---|
1 #!/usr/bin/python | 1 #!/usr/bin/env python |
2 | 2 |
3 #/* | 3 #/* |
4 # * ATC - Air Traffic Controller simulation game | 4 # * ATC - Air Traffic Controller simulation game |
5 # * | 5 # * |
6 # * Copyright (C) 2004-2007 Josef "Jeff" Sipek <jeffpc@josefsipek.net> | 6 # * Copyright (C) 2004-2007 Josef "Jeff" Sipek <jeffpc@josefsipek.net> |
13 # * but WITHOUT ANY WARRANTY; without even the implied warranty of | 13 # * but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 # * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 14 # * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 # * GNU General Public License for more details. | 15 # * GNU General Public License for more details. |
16 # */ | 16 # */ |
17 | 17 |
18 version = "0.10-pre2" | 18 import os, sys |
19 | 19 |
20 try: | 20 basedir = os.path.dirname(sys.argv[0]) |
21 import sys | |
22 import threading | |
23 import pygame | |
24 | |
25 import atc_config | |
26 | |
27 import atc_colors | |
28 import atc_utils | |
29 import atc_plane | |
30 import atc_message | |
31 | |
32 import atc_single | |
33 except ImportError, err: | |
34 print "Couldn't load module %s" % (err) | |
35 sys.exit() | |
36 | 21 |
37 size = width, height = 1024, 768 | 22 import atcgame.mainmenu |
38 | 23 |
39 def main(): | 24 # a hack to make things run from current dir without having to install |
40 """ Main fn to run the main thread """ | 25 sys.path.insert(0, os.path.join(basedir,"atcgame")) |
41 | |
42 # Init | |
43 pygame.init() | |
44 screen = pygame.display.set_mode(size) | |
45 pygame.display.set_caption('Air Traffic Controller (' + version + ')') | |
46 | |
47 # background music | |
48 try: | |
49 pygame.mixer.init() | |
50 except pygame.error: | |
51 print "Could not init sound" | |
52 sys.exit(1) | |
53 #atc_utils.playmusic("some.mp3"); | |
54 | 26 |
55 # Set background | 27 atcgame.mainmenu.main(os.path.join(basedir,"data")) |
56 background = pygame.Surface(screen.get_size()).convert() | |
57 background.fill(atc_colors.black) | |
58 | |
59 (splash_image, splash_rect) = atc_utils.load_png('data/image/splash.png') | |
60 background.blit(splash_image, (0, 0)) | |
61 | |
62 #blit! | |
63 screen.blit(background, (0, 0)) | |
64 pygame.display.flip() | |
65 | |
66 optsel = 0 | |
67 menustr = ('single', 'multi', 'quit') | |
68 | |
69 while 1: | |
70 event = pygame.event.wait() | |
71 if event.type == pygame.QUIT: | |
72 sys.exit() | |
73 if event.type == pygame.KEYDOWN: | |
74 if event.key == pygame.K_UP: | |
75 optsel = (optsel + 2) % 3 | |
76 if event.key == pygame.K_DOWN: | |
77 optsel = (optsel + 1) % 3 | |
78 if event.key == pygame.K_RETURN: | |
79 optsel = optsel | 0x10 | |
80 if optsel == 0x12: | |
81 sys.exit() | |
82 | |
83 screen.blit(background, (0, 0)) | |
84 | |
85 (menu_img, menu_rect) = atc_utils.load_png('data/image/menu_' + menustr[optsel & 3] + '.png') | |
86 screen.blit(menu_img, ((width - 334)/2.0, (height - 225)/2.0)) | |
87 | |
88 pygame.display.flip() | |
89 | |
90 if (optsel & 0x10): | |
91 optsel = optsel & 3 | |
92 if (optsel == 0): # single player | |
93 atc_single.startgame(screen) | |
94 if (optsel == 1): # multi player | |
95 pass # FIXME: implement | |
96 | |
97 if (__name__ == '__main__'): | |
98 main() |