def fire(self, mouse_pos, collidables): """Fires A Projectile :param mouse_pos: The mouse position used to calculate the angle to fire the projectile. :param collidables: A list of objects a projectile can collide with. """ if not self.projectile: if self.current_weapon == 'Arc Shot': self.projectile = GroupSingle(Explosive(cycle(self.strips['magic']), self.rect.midtop, self.calc_angle( mouse_pos), collidables, self.power, 8, 3)) else: self.projectile = GroupSingle(Beam_Shot(cycle(self.strips['magic']), self.rect.midtop, self.calc_angle( mouse_pos), collidables, self.power, 6, 2))
def run_game(): pygame.init() settings = game_settings.Settings() screen = pygame.display.set_mode(settings.resolution) snake = Snake(screen, settings) pygame.display.set_caption("Snake") my_tail = [] x, y = gf.generate_randoms() food = GroupSingle(Food(snake, screen, x, y)) tails = OrderedUpdates() gf.initialise_snake(snake, screen, my_tail, tails, settings) button = Play_button(screen, settings, "Play") end_game_screen = EndGameScreen(screen, settings, "Game Over") score = Score(screen, settings) clock = pygame.time.Clock() gametime = GTime(clock) while True: screen.fill(settings.bg_color) score.draw_me() gf.check_events(snake, food, screen, my_tail, tails, settings, button, gf, end_game_screen, score, gametime) if settings.game_active == False: if gf.lose_condition_met(snake, settings, tails, gametime) == False: button.draw_me() if settings.game_active == True: snake.update() tails.update() snake.draw_me() food.update() clock.tick(10) gametime.update() print(gametime.time) pygame.display.flip()
def __init__(self): self._settings = GameSettings() self.score_count = 0 self.can_pipe_move = True self.is_game_over = False pygame.init() self.clock = pygame.time.Clock() self.game_display = display.set_mode( (self._settings.window_width, self._settings.window_height)) self.asset_factory = AssetFactory() self._pipe_group = Group() self._pipe_gaps = Group() self._pipe_generator = PipeGenerator(self.asset_factory, self._settings) max_mum_pipes = int( self._settings.window_width / (self._settings.pipe_width + self._settings.pipe_distance)) self._max_num_pipe_parts = max_mum_pipes * PipeGenerator.NUM_PIPE_PARTS self.__initialize_pipes__() self.flappy_bird_img = self.asset_factory.create_flappy_bird_image( BIRD_SIZE) self.flappy_bird = FlappyBird(BIRD_START_POS, self.flappy_bird_img) self.flappy_bird_group = GroupSingle(self.flappy_bird) self.bg_img = self.asset_factory.create_bg( self._settings.window_width, self._settings.window_height)
def prep_blue_boss_health(self): """Prepare to drawn blue boss track.""" self.boss_health = GroupSingle() boss_health = BlueBossHealth(self.ai_settings, self.screen) hp_image = boss_health.hp_images[self.blue_boss_hp] boss_health.image = hp_image.copy() boss_health.rect.x = 500 boss_health.rect.y = 50 self.boss_health.add(boss_health)
def prep_red_boss_health(self): """Prepare to drawn red boss health.""" self.boss_health = GroupSingle() boss_health = RedBossHealth(self.ai_settings, self.screen) hp_image = boss_health.hp_images[self.red_boss_hp] boss_health.image = hp_image.copy() boss_health.rect.x = 500 boss_health.rect.y = 50 self.boss_health.add(boss_health)
def runGame(): pygame.init() ai_settings = Settings() screen = pygame.display.set_mode( (ai_settings.screenWidth, ai_settings.screenHeight)) pygame.display.set_caption("Alien Invasion") clock = pygame.time.Clock() # Play button play_button = Button(ai_settings, screen, "Play Game") high = highScore(ai_settings, screen, "High Score") # game stats stats = GameStats(ai_settings) sb = Scoreboard(ai_settings, screen, stats) # ship and bullets ship = Ship(ai_settings, screen) bullets = Group() # aliens and lasers aliens = Group() lasers = Group() ufo = GroupSingle() #Bunker bunkers = Group() gf.create_fleet(ai_settings, screen, ship, aliens) startScreen = Start(ai_settings, screen) soundFile = vlc.MediaPlayer("files/SpaceInvaders.mp3") while True: clock.tick(62) gf.check_events(ai_settings, screen, stats, sb, play_button, ship, aliens, bullets, bunkers, high, ufo) if stats.game_active: soundFile.play() ship.update() gf.update_bullets(ai_settings, screen, stats, sb, ship, aliens, bullets, lasers, bunkers, ufo) gf.update_aliens(ai_settings, screen, stats, sb, ship, aliens, bullets, lasers, bunkers, ufo) gf.fire_laser(ai_settings, screen, aliens, lasers) gf.update_lasers(ai_settings, screen, stats, sb, ship, aliens, bullets, lasers, bunkers, ufo) gf.updateBunkers(bullets, lasers, bunkers, aliens) gf.spawnUFO(ai_settings, screen, ufo) gf.updateUFO(ai_settings, ufo) gf.updateScreen(ai_settings, screen, stats, sb, ship, aliens, bullets, play_button, lasers, bunkers, ufo) elif not stats.game_active and not stats.menu: gf.startGame(play_button, high, startScreen) soundFile.stop() elif stats.menu: gf.printHighScores(screen) soundFile.stop()
def clean_up(): ''' Deletes all blocks that were created. @postcondition: No more objects of BLOCK_TYPE exist in memory. ''' global blocks, block_buffer blocks = get_empty_block_array() block_buffer = GroupSingle(Sprite()) block_buffer.sprite.rect = Rect(0, 0, 0, 0) _blocks_to_check.clear() _blocks_to_clear.clear()
def __init__(self, title='Checkers', log_level=log.INFO, show_fps=False): log.basicConfig(level=log_level) self.show_fps = show_fps self.window_title = title self.game = Board(BOARD_DIM) # Initialize Game Groups self.brown_spaces = RenderUpdates() self.pieces = RenderUpdates() self.piece_selected = GroupSingle() self.space_selected = GroupSingle() self.current_piece_position = ORIGIN self.screen = None self.fps_clock = None self.font = None self.font_rect = None self.background = None self.background_rect = None self.fps_text = None self.fps_rect = None self.winner_text = None self.winner_rect = None
def __init__(self, display: Surface, event_system: EventSystem, images_loader: ImagesLoader): self.__display = display self.__event_system = event_system self.__background = images_loader.smoothscale( images_loader.load_surface( os.path.join('backgrounds', 'stars_blue.png')), self.__display.get_size()) self.__display.blit(self.__background, (0, 0)) player = build_player_ship(self.__display.get_rect().center, (0, 0), 10, self.__event_system, images_loader) self.__player_group = GroupSingle(player) self.__sprites_group = Group(player)
def run_game(): pygame.init() sk_settings = Settings() background = pygame.image.load('images/freetileset/png/BG/BG.png') background = pygame.transform.smoothscale( background, (sk_settings.window_width, sk_settings.window_height)) screen = pygame.display.set_mode( (sk_settings.window_width, sk_settings.window_height)) pygame.display.set_caption('Super Knight') fps = pygame.time.Clock() knight = Knight(sk_settings, screen) sword_container = GroupSingle() arrows_right = Group() arrows_left = Group() zombies_top = Group() zombies_bottom = Group() zombies_left = Group() zombies_right = Group() gf.populate_zombies(sk_settings, screen, zombies_top, zombies_bottom, zombies_left, zombies_right) while True: # everything redrawn every loop before flip called. # Step 1: Check for user input gf.check_events(sk_settings, screen, knight, arrows_right, arrows_left, sword_container) # Step 2: Apply user input to game objects knight.update() gf.update_zombies(sk_settings, screen, knight, arrows_right, arrows_left, zombies_top, zombies_bottom, zombies_left, zombies_right) gf.update_arrows(sk_settings, screen, knight, arrows_right, arrows_left, zombies_top, zombies_bottom, zombies_left, zombies_right) gf.update_sword(sk_settings, screen, knight, sword_container, zombies_top, zombies_bottom, zombies_left, zombies_right) # Step 3: Redraw changes to game objects on the screen gf.update_screen(sk_settings, screen, knight, arrows_right, arrows_left, fps, zombies_top, zombies_bottom, zombies_left, zombies_right, background, sword_container)
def __init__(self, background: Surface, statics: [GameObject], dynamics: [GameObject], ui: [GameObject]): self.background: Surface = background # Cached background with every statics blighted on it self.__background: Surface = None # Objects that are not supposed to move and that will be blited onto the background only once # but will still receive update() self.statics: Group = Group(statics) # Objects that will change appearance in some way and will be rendered individually self.dynamics: ScrollGroup = ScrollGroup(GlobalSettings.RESOLUTION, dynamics) # Objects that are not supposed to live in world space but in camera space self.ui: RenderUpdates = RenderUpdates(ui) # Layers used for collision masks self.layers: Dict[Layers, Group] = { Layers.ENVIRONMENT: Group(), Layers.PLAYER: GroupSingle(), Layers.ENEMY: Group(), Layers.PROJECTILE: Group() } self.__state_dirty: bool = True
def run(self): self.background_sound.set_volume(0.3) self.background_sound.play(loops=-1) background_filename = join('gfx', 'bg_big.png') self.background = pygame.image.load(background_filename).convert() self.elements['score'] = GroupSingle(ScoreSprite(self)) self.elements['exploding_asteroids'] = ExplodingAsteroidsGroup() self.elements['lasers'] = Group() self.elements['asteroids'] = AsteroidGroup(join('gfx', 'asteroid.png'), self) self.elements['ship'] = ShipGroup( sprite=Ship(join('gfx', 'ship.png'), 48, 48, self)) while True: self.player_input() self.events() if self.input.quit_pressed: exit(0) self.update() self.draw() self.detect_collision() time_passed = self.clock.tick(30)
self.image = load('imagens/Cometa_ofc.png') self.rect = self.image.get_rect(center=(800, randint(20, 580))) def update(self): global perdeu self.rect.x -= 0.1 if self.rect.x == 0: self.kill() grupo_cometas = Group() grupo_balas = Group() foguete = Foguete(grupo_balas) grupo_foguete = GroupSingle(foguete) grupo_cometas.add(Cometa()) clock = Clock() abates = 0 round = 0 perdeu = False vida_foguete = 3 pygame.mixer.music.load("sons/musica_fundo.ogg") pygame.mixer.music.set_volume(0.1) pygame.mixer.music.play(-1) while True: clock.tick(120)
def run(self): log.debug('starting game') log.debug('initializing screen') self.screen = self._screen_init() log.debug('getting font') self.font = pygame.font.Font(None, 36) log.debug('loading background') self.background, self.background_rect = self._get_background() log.debug('building initial game board') self._board_setup(brown_spaces=self.brown_spaces) log.debug('initializing game pieces') for player, x, y in self.game.start_positions(): new_piece = PieceSprite(player) self.game.add_piece(new_piece, (x, y)) new_piece.update_from_board() self.pieces.add(new_piece) log.debug('drawing initial content to screen') self.screen.blit(self.background, ORIGIN) pygame.display.flip() self.piece_selected = GroupSingle() self.space_selected = GroupSingle() self.current_piece_position = ORIGIN self.fps_clock = Clock() self._draw_fps() # Event loop while True: self._clear_items() for event in pygame.event.get(): if event.type == QUIT: self._quit() if event.type == MOUSEBUTTONDOWN: # select a piece log.debug('mouse pressed') self._select_piece(event) if event.type == MOUSEBUTTONUP: # let go of a piece log.debug('mouse released') self._drop_piece(event) if pygame.event.get_grab(): # drag selected piece around log.debug('dragging') self._drag_piece() self._draw_items() self.fps_clock.tick(60) # Waits to maintain 60 fps # TODO: Use display.update instead pygame.display.flip()
def run_game(): pygame.mixer.pre_init(44100, -16, 2, 2048) pygame.mixer.init() pygame.init() ai_settings = Settings() screen = pygame.display.set_mode( (ai_settings.screen_width, ai_settings.screen_height)) pygame.display.set_caption("Alien Invasion") ship = Ship(ai_settings, screen) stats = GameStats(ai_settings) hud = Hud(ai_settings, screen, stats, ship) play_button = Button(screen, "Start") bullets = Group() aliens = Group() alien_bullets = Group() health = Group() ammo = Group() used_shields = Group() bosses = GroupSingle() boss_shields = GroupSingle() clock = pygame.time.Clock() boss_bullets = Group() black_holes = GroupSingle() ai_settings.state = ai_settings.running # Main game cycle. while True: dt = clock.tick() gf.check_events(ai_settings, screen, stats, hud, play_button, ship, aliens, bullets, used_shields) gf.check_keys_pressed(ship) if ai_settings.state == ai_settings.running: if stats.game_active: ship.update() gf.update_ship_shield(ship, alien_bullets, used_shields, boss_bullets) gf.update_bullets(ai_settings, screen, stats, hud, ship, aliens, bullets, alien_bullets, health, ammo, bosses, boss_bullets, boss_shields, black_holes) gf.update_aliens(ai_settings, screen, stats, hud, ship, aliens, bullets, alien_bullets, health, ammo, used_shields) gf.fire_alien_bullets(ai_settings, screen, stats, ship, aliens, alien_bullets, dt) gf.update_alien_bullets(ai_settings, screen, stats, hud, ship, aliens, bullets, alien_bullets, health, ammo, used_shields) if stats.stage == ai_settings.boss_stages[0]: gf.update_green_boss(ai_settings, screen, stats, hud, ship, bullets, used_shields, bosses, boss_bullets, boss_shields, bosses) gf.fire_green_boss_bullets(ai_settings, screen, dt, bosses, boss_bullets) gf.update_green_boss_bullets(ai_settings, screen, stats, hud, ship, bullets, used_shields, bosses, boss_bullets, boss_shields, black_holes) gf.update_green_boss_shield(hud, bullets, boss_shields) elif stats.stage == ai_settings.boss_stages[1]: gf.update_red_boss(ai_settings, screen, stats, hud, ship, bullets, used_shields, bosses, boss_bullets, boss_shields, black_holes) gf.update_red_boss_shield(hud, bullets, boss_shields) gf.fire_red_boss_bullets(ai_settings, screen, ship, dt, bosses, boss_bullets) gf.update_red_boss_bullets(ai_settings, screen, stats, hud, ship, bullets, used_shields, bosses, boss_bullets, boss_shields, black_holes) elif stats.stage == ai_settings.boss_stages[2]: gf.update_blue_boss(ai_settings, screen, stats, hud, ship, bullets, used_shields, bosses, boss_bullets, boss_shields, black_holes) gf.update_blue_boss_shield(hud, bullets, boss_shields) gf.fire_blue_boss_bullets(ai_settings, screen, dt, bosses, boss_bullets) gf.update_blue_boss_bullets(ai_settings, screen, stats, hud, ship, bullets, used_shields, bosses, boss_bullets, boss_shields, black_holes) gf.create_black_hole(ai_settings, screen, ship, dt, black_holes) gf.update_black_hole(ai_settings, screen, stats, hud, ship, bullets, used_shields, dt, bosses, boss_bullets, boss_shields, black_holes) gf.update_ship_health(stats, hud, ship, health) gf.update_ship_ammo(stats, hud, ship, ammo) elif ai_settings.state == ai_settings.paused: pass if ai_settings.state == ai_settings.running: gf.update_screen(ai_settings, screen, stats, hud, ship, aliens, bullets, alien_bullets, play_button, health, ammo, used_shields, dt, bosses, boss_bullets, boss_shields, black_holes) else: pass
def main(): # initialze pygame pygame.init() screen = pygame.display.set_mode(SCREEN_SIZE) bounds = screen.get_rect() # initialize the game player = Player(bounds.center, bounds) player_grp = GroupSingle(player) enemies = Group() spawn_counter = 0 fast_spawn_counter = 0 score = 0 font = pygame.font.Font(None, 40) # game loop done = False clock = pygame.time.Clock() while not done: # input for event in pygame.event.get(): if event.type == QUIT: done = True elif event.type == KEYDOWN and event.key == K_ESCAPE: done = True elif event.type == MOUSEBUTTONDOWN and event.button == 1: player.shoot() elif event.type == KEYDOWN and event.key == K_SPACE and not player.alive( ): player = Player(bounds.center, bounds) player_grp.add(player) score = 0 for enemy in enemies: enemy.kill() # same as enemies.empty() # update player_grp.update() player.bullets.update() enemies.update() # spawn enemies spawn_counter += 1 if spawn_counter >= 10: n = randrange(4) for i in range(n): x = randrange(bounds.width - Enemy.width) enemy = Enemy((x, 0), bounds) enemies.add(enemy) spawn_counter = 0 # fast spawn fast_spawn_counter += 1 if fast_spawn_counter >= 45: x = randrange(bounds.width - FastEnemy.width) enemy = FastEnemy((x, 0), bounds) enemies.add(enemy) fast_spawn_counter = 0 # collisions groupcollide(player_grp, enemies, True, False) for enemy in groupcollide(enemies, player.bullets, True, True): if player.alive(): score += 1 # draw screen.fill(BG_COLOR) player_grp.draw(screen) player.bullets.draw(screen) enemies.draw(screen) score_text = font.render("Score: %08d" % score, False, (255, 255, 255)) screen.blit(score_text, (5, 5)) if not player.alive(): gameover = font.render("Press Space to Respawn", False, (255, 255, 255)) rect = gameover.get_rect() rect.center = screen.get_rect().center screen.blit(gameover, rect) pygame.display.flip() clock.tick(30)
def main(): """ Main Program """ pygame.init() # Set the height and width of the screen size = [constants.SCREEN_WIDTH, constants.SCREEN_HEIGHT] screen = pygame.display.set_mode(size) bounds = screen.get_rect() pygame.display.set_caption("Super Alien Assault!") # Load the sound mixer: pygame.mixer.pre_init(44100, -16, 2, 2048) # This is supposed to help stop sound lag # Create the player player = Player(bounds.center, bounds) player_grp = GroupSingle(player) # Create an enemy enemies = pygame.sprite.Group() # Create all the levels lindex = random.randrange(3, 9) level_list = [] level_list.append(levels.Level_01(player)) level_list.append(levels.Level_02(player)) level_list.append(levels.Level_03(player)) for i in range(lindex): level_list.append(levels.Level_01(player)) level_list.append(levels.Level_02(player)) level_list.append(levels.Level_03(player)) # Initialize variables score = 0 spawn_counter = 0 tween_diff = 1 # Select the font to use font = pygame.font.SysFont("calibri", 48) # Set the current level current_level_no = 0 current_level = level_list[current_level_no] # List of each block block_list = pygame.sprite.Group() # Set current level for player and inital x,y position player.level = current_level player.rect.x = 340 player.rect.y = 200 # Loop until the user clicks the close button. done = False # Used to manage how fast the screen updates clock = pygame.time.Clock() # Play "Hot Nights" by Beardmont / Three Chain Links # Available under Creative Commons attribution license from: # https://soundcloud.com/beardmont pygame.mixer.music.load('HotNights.ogg') pygame.mixer.music.set_endevent(pygame.constants.USEREVENT) pygame.mixer.music.play() # -------- Main Program Loop ----------- while not done: for event in pygame.event.get(): if event.type == pygame.QUIT: done = True elif event.type == pygame.constants.USEREVENT: # This event is triggered when the song stops playing. # # Next, play "Happiest Days" by Beardmont / Three Chain Links # Available under Creative Commons attribution license from: # https://soundcloud.com/beardmont pygame.mixer.music.load('HappiestDays.ogg') pygame.mixer.music.play() elif event.type == pygame.KEYDOWN: if event.key == pygame.K_ESCAPE: done = True if event.key == pygame.K_q: done = True if event.key == pygame.K_LEFT: player.go_left() if event.key == pygame.K_RIGHT: player.go_right() if event.key == pygame.K_UP: player.jump() if event.key == pygame.K_SPACE: player.shoot() if event.key == pygame.K_r and not player.alive(): main() elif event.type == pygame.KEYUP: if event.key == pygame.K_LEFT and player.change_x < 0: player.stop() if event.key == pygame.K_RIGHT and player.change_x > 0: player.stop() # Update items in the level current_level.update() player_grp.update() player.bullets.update() player.bulletcasings.update() enemies.update() # Messing around with easing the enemy spawn counter # They should gradually trickle in at first and then build # to a flood of enemies then recede kind of like a tide spawn_counter += (101 - spawn_counter) * .1 if spawn_counter >= 100: n = random.randrange(3) for i in range(n): x = random.randint(900, 1000) y = random.randint(100, 520) enemy = Enemy((x, y)) enemies.add(enemy) spawn_counter = 0 # Collision between player and enemies results in player death groupcollide(player_grp, enemies, True, False) # Add 1 point to score for every enemy the player kills for enemy in groupcollide(enemies, player.bullets, True, True): if player.alive(): score += 1 # If the player gets near the right side, shift the world left (-x) if player.rect.x >= 310: diff = player.rect.x - 310 # add some tweening/easing for momentum tween_diff += (diff - tween_diff) * .1 player.rect.x = 310 current_level.shift_world(int(-tween_diff)) # also adjust enemies and bulletcasings by the world shift for enemy in enemies: enemy.rect.x += (int(-tween_diff)) for bulletcasing in player.bulletcasings: bulletcasing.rect.x += (int(-tween_diff)) # If the player gets near the left side, shift the world right (+x) if player.rect.x <= 290: diff = 290 - player.rect.x # add some tweening/easing for momentum tween_diff += (diff - tween_diff) * .1 player.rect.x = 290 current_level.shift_world(int(tween_diff)) # also adjust enemies and bulletcasings by the world shift for enemy in enemies: enemy.rect.x += (int(tween_diff)) for bulletcasing in player.bulletcasings: bulletcasing.rect.x += (int(tween_diff)) # If the player gets to the end of the level, go to the next level current_position = player.rect.x + current_level.world_shift if current_position < current_level.level_limit: player.rect.x = 120 if current_level_no < len(level_list) - 1: current_level_no += 1 current_level = level_list[current_level_no] player.level = current_level # ALL CODE TO DRAW SHOULD GO BELOW THIS COMMENT current_level.draw(screen) player_grp.draw(screen) player.bullets.draw(screen) player.bulletcasings.draw(screen) enemies.draw(screen) # Blit the current score score_text = font.render("Score: %08d" % score, True, constants.PEACH) screen.blit(score_text, (5, 5)) # If player dies, blit the respawn menu if not player.alive(): gameover = font.render("Press R to Respawn or ESC to Quit", True, constants.PEACH) rect = gameover.get_rect() rect.center = screen.get_rect().center screen.blit(gameover, rect) # ALL CODE TO DRAW SHOULD GO ABOVE THIS COMMENT # Limit to 60 frames per second clock.tick(60) # Go ahead and update the screen with what we've drawn. pygame.display.flip() # Be IDLE friendly. If you forget this line, the program will 'hang' # on exit. pygame.quit()
self.image = load('images/inimigo_1.png') self.rect = self.image.get_rect(center=(800, randint(20, 580))) def update(self): global perdeu self.rect.x -= 0.1 if self.rect.x == 0: self.kill() perdeu = True grupo_inimigos = Group() grupo_torradas = Group() dunofausto = Dunofausto(grupo_torradas) grupo_duno = GroupSingle(dunofausto) grupo_inimigos.add(Virus()) clock = Clock() mortes = 0 round = 0 perdeu = False while True: # Loop de eventos clock.tick(120) # FPS if round % 120 == 0: if mortes < 20:
from core import config from core import color from game import gamedata ### Constants ################################################################## ALARM_LINE = 2 BLOCK_TYPE = None CELL_SIZE = (32, 32) COMBOS = tuple(config.load_sound('combo%d.wav' % i) for i in range(1, 6)) SIZE = (20, 12) #(width, height) RECT = Rect(0, 0, get_surface().get_width(), SIZE[1] * CELL_SIZE[1]) ################################################################################ ### Globals #################################################################### blocks = None block_buffer = GroupSingle(Sprite()) _blocks_to_check = set() _blocks_to_clear = set() _block_clear = config.load_sound('clear.wav') block_buffer.sprite.rect = Rect(0, 0, 0, 0) ################################################################################ def any_active(): s = BLOCK_TYPE.STATES for i in BLOCK_TYPE.GROUP: if i.state not in {s.IDLE, s.ACTIVE}: #If this block is moving... return True
player = Player( SpriteSheet("resources/img/player.png").images_at( util.gen_sprite_list(7, 7, 128, 192, 0), [255, 0, 255]), 64, Vector2(128, pi_globals.screenSize[1] / 2.0)) player.animController.isEnabled = True # projectile = Projectile(SpriteSheet("resources/img/paper_animation.png").image_at(util.gen_sprite_list(26, 10, 50, 50, 0), [255, 255, 255]), 25, player.position, Vector2(25, 25), 0.0) def endThrowFrameEvent(targetPlayer): targetPlayer.animController.playingAnimationIndex = 0 player.animController.getAnimation(1).setFrameEvent(5, endThrowFrameEvent) playerGroup = GroupSingle(player) projectileGroup = Group() # Joystick initialization # TODO Move joystick stuff to a input management file pygame.joystick.init() hasJoystick = False joystick = None if pygame.joystick.get_count() > 0: joystick = pygame.joystick.Joystick(0) joystick.init() hasJoystick = joystick.get_numaxes() >= 2 print("Has Joystick: " + str(hasJoystick))