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
|
"""game module, place for global game state"""
import os
from pygame.rect import Rect
from cStringIO import StringIO
version = "1.0"
#various data constants
start_lives = 3
ship_fastspeed = 10
ship_slowspeed = 6
guard_speed = 5
guard_fire = .01
shot_speed = 4
arena = Rect(55, 50, 590, 490)
timeleft = 0.0
timetick = 0.0
timefactor = 14 #how quickly time drops (bigger = slower)
text_length = 80 #frames text is displayed in-game
news_url = 'http://shredwheat.zopesite.com/solarwolf/thenews'
player = None
name_maxlength = 10 #longest name
max_players = 5 #most player accounts available
#current gamehandler class instance
#this should be set by function creating new handler
handler = None
#FpsClock class, set in main.py
fpsclock = None
def get_resource(filename):
fullname = os.path.join('data', filename)
return fullname
def make_dataname(filename):
if os.name == 'posix':
home = os.environ['HOME']
fullhome = os.path.join(home, '.solarwolf')
if not os.path.isdir(fullhome):
try: os.mkdir(fullhome, 0755)
except OSError: fullhome = home
filename = os.path.join(fullhome, filename)
filename = os.path.abspath(filename)
filename = os.path.normpath(filename)
return filename
|