コード例 #1
0
ファイル: game.py プロジェクト: mando222/PyGameEngine
    def __init__(self):
        init_dirs()
        self.running_config = config_reader() #read startup options from config file
        self.log_file = self.running_config.read_config('logging', 'log_file', 'string')
        self.log_dir = self.running_config.read_config('logging', 'log_dir', 'string')
        self.log_level = self.running_config.read_config('logging', 'log_level', 'string')
        self.logging_mode = self.running_config.read_config('logging', 'logging_mode', 'string')
        initLogging(self.log_file, self.log_dir, self.log_level,self.logging_mode) #start the logger
        self.initStatus = pygame.init() #start pygame modules
        self.key_bindings = key_bindings()
        logging.info('Game Starting with %i moduals Succeding and %i Failures', self.initStatus[0], self.initStatus[1])

        self.display_width = self.running_config.read_config('graphics', 'display_width', 'int')
        self.display_height = self.running_config.read_config('graphics', 'display_height', 'int')
        logging.info('Screen resolution set to %i x %i', self.display_width, self.display_height)

        self.game_display = pygame.display.set_mode((self.display_width, self.display_height))
        pygame.display.set_caption('PyGameEngine')
        logging.info('Game Has Started Without Errors')
        self.clock = pygame.time.Clock()

        #Networking support 



        #Setup background
        self.background = load_image('whitebackground')
        self.menu_background = load_image('whitebackground')
        self.game_display.blit(self.menu_background, (0, 0))

        #Setup global arrays
        self.unit_list = []
        self.running = True
        self.game_state = 'main_menu'
        self.menu=menu_object(self.display_height, self.display_width)
コード例 #2
0
ファイル: game.py プロジェクト: tomalexander/h_and_b
 def __init__(self):
     """Main running function"""
     self.windowx = 680
     self.windowy = 800
     pygame.init()
     self.clock = pygame.time.Clock()
     self.set_up_screen()
     self.time_since_last_frame = 0.0
     self.enemy_text = open("enemies.txt").readlines()
     self.enemy_data = self.interp_enemies(self.enemy_text)
     self.text_text = open("text_disp.txt").readlines()
     self.text_data = self.interp_text(self.text_text)
     self.text_list = []
     self.debris_list = []
     self.rock_list = []
     self.sbear_list = []
     self.wbear_list = []
     self.particle_list = []
     self.boss = None
     self.boss_killed = False
     self.boss_spawned = False
     self.lady_spawned = False
     self.lady_koi = None
     self.lives = 6
     self.last_death = -2000
     self.immortal_time = 2000
     self.player = player(self.windowx, self)
     self.distance = 0
     self.worldspeed = 1 #distance per ms for river image movement
     self.riverimg = pygame.image.load("img/river1.png").convert()
     #self.landimgl = pygame.image.load("img/landproxy.png").convert()
     #self.landimgr = pygame.image.load("img/landproxy.png").convert()
     #self.landimgr = pygame.transform.rotate(self.landimgl, 180)
     self.landimgl = pygame.image.load("img/good_grass_left.png").convert_alpha()
     self.landimgr = pygame.image.load("img/good_grass_right.png").convert_alpha()
     self.sidebarimg = pygame.image.load("img/sidebar.png").convert()
     self.heartimg = pygame.image.load("img/heart.png").convert_alpha()
     self.key_bindings = key_bindings()
     self.screen_rect = pygame.Rect(0,0,self.windowx,self.windowy)
     self.player_killed = False
     self.killedforealz = False
     self.deaddraw = True
     self.deaddrawnum = 0 #a counter to make the player flicker when respawning
     #self.font32 = pygame.font.Font(None, 32) #Temp Font
     self.font32 = pygame.font.Font("fonts/SVBasicManual.ttf", 20)
     self.aqua32 = pygame.font.Font("fonts/Aquanaut.ttf", 40)
     #final boss stuff
     #self.bad_koi = evil_koi(self.windowx)
     self.bad_projectiles = []
     self.music = game_music()
     self.distance_bar = generic_bar(0, 200000, (0,0,0), (0,0,0), (255,255,255), 620, 100, 20, 300)
     self.energy_bar = generic_bar(0, 300, (255,0,0), (255,255,0), (255,255,255), 645, 100, 20, 300)
     self.dont_exit = True
     self.lady_time = 0
     self.fire_particle_image = pygame.image.load("img/fire_particle.png").convert_alpha()
     self.water_particle_image = pygame.image.load("img/water_particle.png").convert_alpha()
     self.rock_particle_image = pygame.image.load("img/rock_particle.png").convert_alpha()
コード例 #3
0
    def __init__(self):
        """The main running function"""
        #initialize window stuff
        self.windowx = 680
        self.windowy = 800
        pygame.init()
        self.clock = pygame.time.Clock()
        self.initialize_screen()
        self.frametime = 0.0
        self.no_exit = True
        self.distance = 0
        self.lives = 3
        self.immortal = 2000
        self.last_death = -2000
        self.player_killed = False
        self.in_level = False
        self.money = 0
        self.font32 = pygame.font.Font("img/SVBasicManual.ttf", 20)
        self.addons = [pygame.image.load("img/chip.png"), pygame.image.load("img/lightning.png"), pygame.image.load("img/eraser.png"), pygame.image.load("img/cube.png")]
        
        self.player = player(self)
        self.key_bindings = key_bindings()
        self.enemies = []
		
        self.myshop = Shop(self.windowx, self.windowy)
        self.shopactive = True
		
		#images 'n' such
        self.background = pygame.image.load("img/floor2.png")#.convert()
        self.deaddraw = True
        self.deaddrawnum = 0 #makes player flicker when respawning
        self.levelactive = False
        self.oldflag = self.levelactive
        self.frame = 0
        
        self.run(False)