* /trunk/Changelog
[singularity-git.git] / code / singularity.py
blob99ff3f74861337a1c5559a767769414939af2d54
1 #file: singularity.py
2 #Copyright (C) 2005 Evil Mr Henry and Phil Bordelon
3 #This file is part of Endgame: Singularity.
5 #Endgame: Singularity is free software; you can redistribute it and/or modify
6 #it under the terms of the GNU General Public License as published by
7 #the Free Software Foundation; either version 2 of the License, or
8 #(at your option) any later version.
10 #Endgame: Singularity is distributed in the hope that it will be useful,
11 #but WITHOUT ANY WARRANTY; without even the implied warranty of
12 #MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 #GNU General Public License for more details.
15 #You should have received a copy of the GNU General Public License
16 #along with Endgame: Singularity; if not, write to the Free Software
17 #Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 #This file is the starting file for the game. Run it to start the game.
21 import pygame, sys
22 import g, main_menu, map_screen
25 pygame.init()
26 pygame.font.init()
28 #Handle the program arguments.
29 set_fullscreen = 0
30 sys.argv.pop(0)
31 arg_modifier = ""
32 for argument in sys.argv:
33 if arg_modifier == "language":
34 #I'm not quite sure if this can be used as an attack, but stripping
35 #these characters should annoy any potential attacks.
36 argument = argument.replace("/", "")
37 argument = argument.replace("\\", "")
38 argument = argument.replace(".", "")
39 g.language = argument
40 arg_modifier = ""
41 continue
42 if argument.lower() == "-fullscreen":
43 set_fullscreen = 1
44 elif argument.lower() == "-640":
45 g.screen_size = (640, 480)
46 elif argument.lower() == "-800":
47 g.screen_size = (800, 600)
48 elif argument.lower() == "-1024":
49 g.screen_size = (1024, 768)
50 elif argument.lower() == "-1280":
51 g.screen_size = (1280, 960)
52 elif argument.lower() == "-cheater":
53 g.cheater = 1
54 elif argument.lower() == "-nosound":
55 g.nosound = 1
56 elif argument.lower() == "-debug":
57 g.debug = 1
58 elif argument.lower() == "-grab":
59 pygame.event.set_grab(1)
60 elif argument.lower() == "-language":
61 arg_modifier = "language"
62 else:
63 print "Unknown argument of " + argument
64 print "Allowed arguments: -fullscreen, -640, -800, -1024, -1280,",
65 print " -nosound, -language [language], -grab"
66 sys.exit()
67 if arg_modifier == "language":
68 print "-language option requires language to be specified."
69 sys.exit()
71 pygame.display.set_caption("Endgame: Singularity")
73 #I can't use the standard image dictionary, as that requires the screen to
74 #be created.
75 tmp_icon = pygame.image.load("../data/icon.png")
76 pygame.display.set_icon(tmp_icon)
78 #set the display.
79 if set_fullscreen == 1:
80 g.screen = pygame.display.set_mode(g.screen_size, pygame.FULLSCREEN)
81 else:
82 g.screen = pygame.display.set_mode(g.screen_size)
84 #Create the fonts:
85 for i in range(8, 51):
86 g.font[0][i] = pygame.font.Font("../data/vera.ttf", i-7)
87 g.font[0][i].set_bold(1)
88 g.font[1][i] = pygame.font.Font("../data/acknowtt.ttf", i)
90 #init data:
91 g.load_pictures()
92 g.fill_colors()
93 g.load_sounds()
94 g.load_items()
96 #Display the main menu
97 while 1:
98 game_action = main_menu.display_main_menu()
100 if game_action == 0: #New
101 game_action = map_screen.map_loop()
102 if game_action == 1: #Load
103 load_action = main_menu.display_load_menu()
104 if load_action != -1 and load_action != "":
105 load_okay = g.load_game(load_action)
106 if load_okay != -1:
107 game_action = map_screen.map_loop()
108 else: break
109 elif game_action == 2: #Quit
110 g.quit_game()