"""game module, place for global game state""" import os from pygame.rect import Rect from cStringIO import StringIO #various data constants name = 'FarBlazer' version = "0.7" version_message = "%s %s" % (name,version) desired_fps = 100 report_fps = 1 add_actor_interval = 40 # frames blast_length_delay = 10 ship_friction = 0.99 ship_fastspeed = 6 ship_slowspeed = 3 ship_blast_delay = 180 # ticks (milliseconds) ship_blast_speed = 9 ship_bomb_height = 440 - 50 ship_bomb_delay = 300 # ticks ship_xthrust = 0.10 ship_ythrust = 0.10 ship_thrust_time = 2 ship_maxvel = 4 ship_minvel = - ship_maxvel ship_thrust_cost = 1 ship_blast_cost = 10 ship_fuel_tick_time = 1000 # frames ship_fuel_tick_cost = 10 flame_interval = 10 # frames to wait between flame changes bomb_turninterval = 10 # ticks rocket_friction = 0.99 rocket_gravity = 0.15 #0.12 # added to dy if fuel == 0 rocket_maxthrust = 1 rocket_launch_dist = 400 rocket_launch_dist_x = -100 rocket_range = 600 rocket_max_vel = 7 ground_height = 500 ground_rect = Rect(0,500,800,4) ground_color = (122,105,92) arena = Rect(0, 35, 800, 395) groundarena = Rect(0, 35, 800, 465) starrect = groundarena groundspeed = 1.0 gravity = 0.07 friction = 0.99 state_transition_time = 300 # ticks to wait before going to next game state start_pos = [-190,200] start_timer = 150 # ticks to wait before starting collision_timer = 3 # how many frames to delay before exploding explosion_time = 70 # how long does explosion stay on screen (ticks) explosion_friction = 0.9 # how fast does explosion slow down ground_explosion_height = 60 # score values point_tbl = { 'none':0, 'storagetank0':20, 'storagetank1':30, 'cactus':0, 'tree0':0, 'tree1':0, 'house':-100, # yep, bombing things with people in them is a no-no 'building':-100, # ditto 'tower':60, 'plane0':40, 'plane1':60, 'radar0':100, 'headquarters':500, 'icbm':400, 'rocket':150, 'rocketlauncher':50, 'balloon':10, 'tank0':100, 'tank1':150, 'fuelship':0, 'fuelbox':0, 'end':0} text_length = 80 #frames text is displayed in-game timeleft = 0 start_fuel = 2000 start_bombs = 30 start_lives = 3 # global variables - should not do this way! score = 0 fuel = 0 bombs = 0 lives = 0 # cheat codes all default to off! shields = 0 infinite_lives = 0 infinite_fuel = 0 infinite_bombs = 0 single_frame = 0 debug_mode = 0 player = None #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, '.starblazer') 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