-
Notifications
You must be signed in to change notification settings - Fork 0
/
4stattack.py
107 lines (83 loc) · 3.16 KB
/
4stattack.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
#!/usr/bin/env python
#########################################################################
# 4st Attack #
#########################################################################
# Created by: #
# Main programming - "slm" - Jeroen Vloothuis #
# Graphics - "The Corruptor" -- [email protected] #
#########################################################################
# Specail thanks: #
# Everyone in #pygame and the opensource community in general #
#########################################################################
# This software is licensed under the GPL - General Public License #
#########################################################################
import os, sys
import pygame, pygame.font, pygame.image, pygame.mixer, pygame.transform
from pygame.locals import *
from startscreen import *
from inisettings import *
import profile
import string
pygame.init()
# Declaration of the variables
images = None
screen = None
def playMusic(datadir):
if pygame.mixer.get_init():
pygame.mixer.music.load( os.path.join(datadir, 'music', '4stattack.ogg') )
pygame.mixer.music.play(-1)
def getOptions(argv):
opts= {}
while argv:
if argv[0][0] == '-':
opts[argv[0]] = argv[1]
argv = argv[2:]
else:
argv = argv[1:]
return opts
def setDisplay(resolution, fullscreen):
if fullscreen == 'yes':
screen = pygame.display.set_mode(resolution, FULLSCREEN)
else:
screen = pygame.display.set_mode(resolution)
pygame.display.set_caption('4st Attack 2')
pygame.mouse.set_visible(1)
pygame.display.init()
pygame.display.Info()
return screen
def loadGraphic(image_name, resolution, themename, datadir):
image_path = os.path.join(datadir, 'themes', themename, resolution, image_name)
image = pygame.image.load(image_path).convert_alpha()
return image
def loadGraphics(file_names, resolution, themename, datadir):
images = {}
for key in file_names.keys():
images[key] = loadGraphic(file_names[key], resolution, themename, datadir)
return images
def quit():
pygame.quit()
os._exit(0)
def main():
options = getOptions(sys.argv)
if options.has_key('-ini'):
ini_settings = IniSettings(options['-ini'])
else:
ini_settings = IniSettings('settings.ini')
settings = ini_settings.settings
datadir = settings['path']['data']
if settings['sound']['music'] == 'yes':
playMusic(datadir)
resolution = settings['video']['resolution']
res = string.split(resolution, 'x')
screen = setDisplay((int(res[0]), int(res[1])), settings['video']['fullscreen'])
# load all images
images = {}
img_files = IniSettings(datadir + '/themes/clean/graphics.ini')
for key in img_files.settings.keys():
images[key] = loadGraphics(img_files.settings[key], resolution, "clean", datadir)
#print "Loading: ", key
locations = IniSettings(datadir + '/themes/clean/'+resolution+'/locations.ini').settings
startscreen = StartScreen(screen, images, locations, ini_settings)
startscreen.run()
if __name__ == '__main__':
main()