def run_game(): #初始化游戏并新建一个屏幕对象 pygame.init() #初始化设置 setting = settings.Settings() #初始化屏幕 screen = pygame.display.set_mode( (setting.screen_width, setting.screen_height)) pygame.display.set_caption('Alien Invasion') #创建统计信息、记分牌 stats = game_stats.GameStats(setting) sb = scoreboard.ScoreBoard(setting, screen, stats) #创建开始按钮 play_button = button.Button(setting, screen, 'Play') #创建一艘飞船、一个子弹编组、一个外星人编组 ai_ship = ship.Ship(screen, setting) bullets = Group() aliens = Group() #创建外星人群 game_function.create_fleet(setting, screen, ai_ship, aliens) #开始游戏循环 while True: #监视键盘和鼠标事件 game_function.check_events(setting, screen, ai_ship, bullets, stats, play_button, aliens, sb) #有命的情况下刷新 if stats.game_active: ai_ship.update() game_function.update_bullets(setting, screen, ai_ship, aliens, bullets, stats, sb) game_function.update_aliens(setting, screen, ai_ship, aliens, bullets, stats, sb) #每次循环重新绘制屏幕 game_function.update_screen(setting, screen, ai_ship, aliens, bullets, stats, play_button, sb)
def __init__(self, screen): """ Constructor for Board class """ # Sprite group which contains player,donkey and priness self.active_sprite_list = pygame.sprite.Group() # Initializes all the platforms for the game self.screen = screen self.platform_zero = landforms.ZeroPlatform() self.platform_one = landforms.FirstPlatform() self.platform_two = landforms.SecondPlatform() self.platform_three = landforms.ThirdPlatform() self.platform_four = landforms.FourthPlatform() # Initializes all the ladders for the game self.broken_ladder_one = ladder.BrokenLadder(200, constants.SCREEN_HEIGHT) self.ladder_two = ladder.Ladder(400, constants.SCREEN_HEIGHT) self.ladder_three = ladder.Ladder(300, constants.ONE_Y) self.ladder_four = ladder.Ladder(550, constants.TWO_Y) self.ladder_five = ladder.Ladder(450, constants.THREE_Y) # Initializes the cage surrounding the princess self.cage_one = cage.CageOne() # Initializes the player and princess for the game self.knight = player.Player() self.lady = princess.Princess(constants.SCREEN_HEIGHT - 100, constants.FOUR_Y) self.knight.set_princess(self.lady) # Add the player and princess the active sprite list self.active_sprite_list.add(self.knight) self.active_sprite_list.add(self.lady) # Set the score board for the game self.score_board = scoreboard.ScoreBoard(self.knight)
PADDING = 20 BORDER_RIGHT = int(SCREEN_WIDTH/2) - PADDING BORDER_LEFT = -int(SCREEN_WIDTH/2) + PADDING BORDER_TOP = int(SCREEN_HEIGHT/2) - PADDING BORDER_BOTTOM = -int(SCREEN_HEIGHT/2) + PADDING screen = turtle.Screen() screen.setup(width=SCREEN_WIDTH, height=SCREEN_HEIGHT) screen.bgcolor("black") screen.title("Snake Game") screen.tracer(0) my_snake = snake.Snake() my_food = food.Food(game_width=SCREEN_WIDTH, game_height=SCREEN_HEIGHT) my_score_board = scoreboard.ScoreBoard(SCREEN_HEIGHT) screen.update() screen.onkey(my_snake.up, "Up") screen.onkey(my_snake.down, "Down") screen.onkey(my_snake.left, "Left") screen.onkey(my_snake.right, "Right") screen.listen() while True: time.sleep(0.1) screen.update() my_snake.move()
import turtle as t import time from snake import Snake import food import scoreboard as sk screen = t.Screen() screen.setup(width=600, height=600) screen.tracer(0) screen.bgcolor("black") screen.title("My snake game ") score = sk.ScoreBoard() my_snake = Snake() my_snake.position() screen.update() food = food.Food() screen.listen() screen.onkey(my_snake.Up, "Up") screen.onkey(my_snake.Down, "Down") screen.onkey(my_snake.Left, "Left") screen.onkey(my_snake.Right, "Right") is_game_on = True while is_game_on: screen.update() time.sleep(0.1) my_snake.move() if my_snake.segments[0].distance(food) < 15: food.refresh()
def game(): import pygame, sys, pygame.mixer from pygame.locals import * import common_pygame import enemy import load_resources import random import ship import background import hud import bonus import menu import effects import particles import smoke import lasers import input import lib.eztext import scoreboard pygame = common_pygame.pygame screen= common_pygame.screen clock = common_pygame.clock #dictionnaries that will contain all our needed resources sounds = dict() single_sprites = dict() sprite_sequences = dict() #create the menu ( we create it here in order to let the menu object read the configuration, #to set the correct screen size menu=menu.Menu() #fill up our dictionnaries (sounds, single_sprites, sprite_sequences) = load_resources.load_resources(pygame) #sprite proprieties being used later laser_height = single_sprites['sprite_laser.png'].get_height() laser_width = single_sprites['sprite_laser.png'].get_width() #lasershoot_width = single_sprites['sprite_lasershoot.png'].get_width() #lasershoot_height = single_sprites['sprite_lasershoot.png'].get_height() #the ship's laser list laserlist = list() lasershoot = 7 tinyfont = pygame.font.Font(None, 16) font = pygame.font.Font(None,32) font2 = pygame.font.Font(None, 150) background = background.BackGen(single_sprites) hud= hud.Hud(single_sprites, menu, sounds) #start the menu menu.init2(single_sprites, sounds, background, hud) menu.launch(0) ship = ship.Ship(single_sprites, sounds, menu, sprite_sequences ) ship.setWeapon(1) ship_top = screen.get_height()-ship.height ship_left = screen.get_width()/2 - ship.width/2 decal_laser_ship_x = (ship.width /2) coord_laser_ship_y = -40 #the enemy laser system lasers = lasers.Lasers(single_sprites, ship) enemy_list = list() compteur = 0 countdown=0 #to know if it's ok to shoot compteur_shoot=int(0) nbAsteroids=0 #current_sprite=0 it=0 #bonus processing scoreBonus=bonus.Bonus(sounds, menu) thegame=True level =-1 spawnedBoss=False while thegame: compteur_shoot=compteur_shoot+1 #every 2 minutes, level up if compteur%(30*60)==0: level=level+1 #level 1 : 3 enemies every 3 seconds if level==1: if compteur%(3*20)==0: boolrand = bool(random.getrandbits(1)) for i in range(1): enemy_list.append(enemy.Enemy( single_sprites, sprite_sequences , sounds, i*80+250+60*int(boolrand), -single_sprites['sprite_enemy.png'].get_height(),boolrand \ , 0, menu)) #print (enemy_list[0].nbAsteroids) if level==2: if compteur%(2*60)==0: boolrand = bool(random.getrandbits(1)) for i in range(6): enemy_list.append(enemy.Enemy( single_sprites, sprite_sequences , sounds, i*80+190+60*int(boolrand), -single_sprites['sprite_enemy.png'].get_height(),boolrand \ , 0, menu)) #print (enemy_list[0].nbAsteroids) if level==3 and not spawnedBoss: enemy_list.append(enemy.Enemy( single_sprites, sprite_sequences , sounds, 400-single_sprites['boss1.png'].get_width()/2, -single_sprites['boss1.png'].get_height(),1 ,\ 2, menu)) spawnedBoss=True #if compteur%(1*60)==0: #boolrand = bool(random.getrandbits(1)) #for i in range(9): #enemy_list.append(enemy.Enemy( single_sprites, sprite_sequences , sounds, #i*80+80+60*int(boolrand), -single_sprites['sprite_enemy.png'].get_height(),boolrand , 0, menu)) #print (enemy_list[0].nbAsteroids) #new asteroids #if ((len(enemy_list)==0) or enemy_list[0].nbAsteroids<=2) and compteur%150==0: if compteur%150==0: boolrand = bool(random.getrandbits(1)) enemy_list.append(enemy.Enemy( single_sprites, sprite_sequences , sounds, random.randrange(0, screen.get_width()), -32,boolrand , 1, menu)) enemy_list[0].nbAsteroids=enemy_list[0].nbAsteroids+1 #if (len(enemy_list)>=0): #print( compteur = compteur +1 background.updatecompteur() clock.tick_busy_loop(30) screen.fill((0,0,0)) #blit the stars and the asteroids background.blitStars() background.blitPlanets() #show the fog background.blitFog() mouse_x,mouse_y=pygame.mouse.get_pos() for event in pygame.event.get(): if event.type == pygame.QUIT: sys.exit() #elif event.type == MOUSEBUTTONDOWN: #sounds['laser.wav'].play() #laserlist.append( (ship.position_ship_x+ship.width/2 -laser_width/2 , #ship.position_ship_y-laser_height)) #lasershoot = 7 if pygame.key.get_pressed()[K_ESCAPE]: #launch menu with resume option menu.launch(1) if pygame.key.get_pressed()[K_LEFT]: if ship.currentspeed_x >=0: ship.currentspeed_x = -5 if ship.currentspeed_x > -20: ship.currentspeed_x = ship.currentspeed_x -1 elif pygame.key.get_pressed()[K_RIGHT]: if ship.currentspeed_x <= 0: ship.currentspeed_x = 5 if ship.currentspeed_x < 20: ship.currentspeed_x = ship.currentspeed_x +1 if pygame.key.get_pressed()[K_DOWN]: if ship.currentspeed_y <= 0: ship.currentspeed_y = 5 if ship.currentspeed_y < 20: ship.currentspeed_y = ship.currentspeed_y +1 elif pygame.key.get_pressed()[K_UP]: if ship.currentspeed_y >= 0: ship.currentspeed_y = -5 if ship.currentspeed_y > -20: ship.currentspeed_y = ship.currentspeed_y -1 if pygame.key.get_pressed()[K_LEFT] ==0 and pygame.key.get_pressed()[K_RIGHT]==0 \ and pygame.key.get_pressed()[K_UP] ==0 and pygame.key.get_pressed()[K_DOWN]==0: ship.currentspeed_y=0 ship.currentspeed_x=0 #are we shooting ? if pygame.key.get_pressed()[K_SPACE]: (compteur_shoot, laserlist) =ship.shoot(laserlist,compteur_shoot, laser_width, laser_height) #update the ships position ship.updatePosition() #blit the right thing ship.blit(compteur) #blit the laser shot fire #if lasershoot >= 0 : #screen.blit(single_sprites['sprite_lasershoot.png'],(ship.position_ship_x+ship.width/2 -lasershoot_width/2, #ship.position_ship_y )) #lasershoot = lasershoot -1 oldLasers = list() #blit the lasers for index in range(len(laserlist)): (currentx, currenty, lasertype) = laserlist[index] if currenty>=-40: #it's a normal laser if lasertype==1: screen.blit(single_sprites['sprite_laser_light.png'],(currentx-29-32,currenty-22-32)) screen.blit(single_sprites['sprite_laser.png'],(currentx,currenty)) currenty = currenty - 15 #it's a plasma ball else : screen.blit(single_sprites['ball1_light.png'],(currentx-10,currenty-10)) screen.blit(single_sprites['ball1.png'],(currentx,currenty)) currenty = currenty - 20 laserlist[index]=(currentx,currenty, lasertype) else: oldLasers.append((currentx,currenty, lasertype)) #purge old lasers for index in range(len(oldLasers)): laserlist.remove(oldLasers[index]) deadEnemies=list() #blit and process the enemies for index in range(len(enemy_list)): oldLasers=enemy_list[index].processHit(laserlist, ship) enemy_list[index].update(ship, lasers) if enemy_list[index].alive==False: deadEnemies.append(enemy_list[index]) #purge old lasers for index in range(len(oldLasers)): laserlist.remove(oldLasers[index]) #purge dead enemies for index in range(len(deadEnemies)): enemy_list.remove(deadEnemies[index]) #blit and process the enemy's lasers lasers.update() #blit the hud level = hud.blit(ship, level) #process ship hurt countdown = ship.processHurt(countdown) if (ship.life<=0): thegame=False #youlost = font2.render("Game over", True, (255,255, 255)) #presskey = font.render("press any key to quit", True, (255,255, 255)) #yourscore = font.render("Your score : "+ str(ship.score), True, (255,255, 255)) youlost = pygame.font.Font("BITSUMIS.TTF",105).render("Game over", True, (255,255, 255)) presskey = pygame.font.Font("BITSUMIS.TTF",23).render("press escape to quit", True, (255,255, 255)) yourscore = pygame.font.Font("BITSUMIS.TTF",30).render("Your score : "+ str(ship.score), True, (255,255, 255)) yourname = pygame.font.Font("BITSUMIS.TTF",55).render("Your name : ", True, (255,255, 255)) #play a the explosion sound menu.play_sound(sounds['explosion2.wav']) #blit the explosion screen.blit(sprite_sequences['sprite_explosion_list_asteroid.png'][3],\ (ship.position_ship_x-64,ship.position_ship_y-64)) #fade to red effects.fadeToColor(255, 0, 0) #scoreBonus.ProcessBonus(ship) particles.blitAndUpdate() smoke.blitAndUpdate() pygame.display.flip() exitloop = True exitcountdown =0 name = "" car = "" txtbx = lib.eztext.Input(maxlength=45, color=(255,50,50), prompt='Your name: ') txtbx.set_pos( 230,180) txtbx.set_font(pygame.font.Font("BITSUMIS.TTF",30)) nametyped = False scoreObj = scoreboard.ScoreBoard() while exitloop: exitcountdown =exitcountdown+ 1 clock.tick_busy_loop(30) screen.fill((0,0,0)) background.updatecompteur() background.blitStars() background.blitPlanets() #show the fog background.blitFog() screen.blit(youlost, (110,35 )) screen.blit(yourscore, (130,150 )) #screen.blit(yourname, (180,330 )) #screen.blit(pygame.font.Font("BITSUMIS.TTF",55)\ #.render(name, True, (255,0, 0)), (300, 330)) screen.blit(presskey, (270,520 )) #car = str(input.keyInput()) #if isinstance(car, str): #name = name + pygame.key.name(car) #print("name : " + name) #input.keyInput() if not nametyped: # update txtbx txtbx.update(pygame.event.get()) # blit txtbx on the sceen #if exitcountdown%20>10: #txtbx.draw(screen) if txtbx.hasTyped() ==False: if exitcountdown%20>10: txtbx.draw(screen) elif nametyped == False: txtbx.draw(screen) if exitcountdown==30: menu.play_sound(sounds["loser.wav"]) if exitcountdown>=30: for event in pygame.event.get(): if event.type == pygame.QUIT: sys.exit() if pygame.key.get_pressed()[K_ESCAPE]: print("exiting") exit() exitloop=False if pygame.key.get_pressed()[K_RETURN]: if not nametyped: scoreObj.addScore(ship.score, txtbx.getText()) nametyped = True scoreObj.printScore() #if pygame.KEYDOWN: #print("exiting") #exit() pygame.display.flip()
def run(self): # The function which runs the game board1 = board.Board(self.screen, 1) stateright = 0 stateleft = 0 stateup = 0 statedown = 0 jumpstate = 0 timer = 0 jumpspeed = 0 donkeytimer = 0 fireballfrequency = (60, 80) lim = randint(fireballfrequency[0], fireballfrequency[1]) scoreboard1 = scoreboard.ScoreBoard("Images/scoreboard.png", board1.getPlayerScore(), self.screen, "Images/liveplayer.png") while 1: quitstate = 0 fireballhitme = 0 self.screen.set_alpha(None) if timer == lim: board1.createfireball() timer = 0 lim = randint(fireballfrequency[0], fireballfrequency[1]) timer += 1 prevScore = board1.getPlayerScore() ladderstate = board1.getLadderCollisions() collectCoin = board1.getCoinCollisions() self.clock.tick(30) pygame.key.set_repeat() for ev in pygame.event.get(): if ev.type == QUIT: quitstate = 1 if not hasattr(ev, 'key'): continue if ev.type == KEYDOWN and (ev.key == K_RIGHT or ev.key == K_d): stateright = 1 if ev.type == KEYUP and (ev.key == K_RIGHT or ev.key == K_d): stateright = 0 if ev.type == KEYDOWN and (ev.key == K_LEFT or ev.key == K_a): stateleft = 1 if ev.type == KEYUP and (ev.key == K_LEFT or ev.key == K_a): stateleft = 0 if ev.type == KEYDOWN and (ev.key == K_UP or ev.key == K_w): stateup = 1 if ev.type == KEYUP and (ev.key == K_UP or ev.key == K_w): stateup = 0 if ev.type == KEYDOWN and (ev.key == K_DOWN or ev.key == K_s): statedown = 1 if ev.type == KEYUP and (ev.key == K_DOWN or ev.key == K_s): statedown = 0 if ev.type == KEYDOWN and ev.key == K_SPACE and jumpstate == 0: jumpstate = 1 jumpspeed = 10 if ev.key == K_ESCAPE: quitstate = 1 if quitstate == 1: if self.confirmquit() == 1: return -1 board1.updatefireballs() donkeytimer += 1 if donkeytimer == 10: donkeytimer = 0 board1.updatedonkey(1) else: board1.updatedonkey(0) if stateup == 1 and ladderstate == 1: board1.key_pressed(3) dead = board1.checkfireballcollision() if dead == 0: if self.askforrestart(board1, scoreboard1) == 1: return -1 else: return 0 elif dead == 1: fireballhitme = 1 jumpstate = 0 if statedown == 1 and ladderstate == 1: board1.key_pressed(4) dead = board1.checkfireballcollision() if dead == 0: if self.askforrestart(board1, scoreboard1) == 1: return -1 else: return 0 elif dead == 1: fireballhitme = 1 jumpstate = 0 if ladderstate == 1: board1.checkplayerlevel() dead = board1.checkfireballcollision() if dead == 0: if self.askforrestart(board1, scoreboard1) == 1: return -1 else: return 0 elif dead == 1: fireballhitme = 1 jumpstate = 0 if stateright == 1: board1.key_pressed(1) dead = board1.checkfireballcollision() if dead == 0: if self.askforrestart(board1, scoreboard1) == 1: return -1 else: return 0 elif dead == 1: fireballhitme = 1 jumpstate = 0 if stateleft == 1: board1.key_pressed(2) dead = board1.checkfireballcollision() if dead == 0: if self.askforrestart(board1, scoreboard1) == 1: return -1 else: return 0 elif dead == 1: fireballhitme = 1 jumpstate = 0 if stateright == 0 and stateleft == 0 and ladderstate == 0: board1.setPlayerstraight() if ladderstate == 1 and jumpstate == 1: jumpstate = 0 if jumpstate == 1: if board1.playerjump(jumpspeed) == 1: jumpstate = 2 jumpspeed = 0 else: jumpspeed -= 2 dead = board1.checkfireballcollision() if dead == 0: if self.askforrestart(board1, scoreboard1) == 1: return -1 else: return 0 elif dead == 1: fireballhitme = 1 jumpstate = 0 if jumpstate == 2: if board1.playerjumpdown(jumpspeed) == 1: jumpstate = 0 jumpspeed = 10 else: jumpspeed += 2 dead = board1.checkfireballcollision() if dead == 0: if self.askforrestart(board1, scoreboard1) == 1: return -1 else: return 0 elif dead == 1: fireballhitme = 1 jumpstate = 0 if ladderstate == 0 and jumpstate == 0: board1.dropplayer() dead = board1.checkfireballcollision() if dead == 0: if self.askforrestart(board1, scoreboard1) == 1: return -1 else: return 0 elif dead == 1: fireballhitme = 1 jumpstate = 0 board1.checkMidAir() if board1.checkwin() == 1: board1.respawnPlayer() board1.initcoins(self.screen) board1.setplayerlives() board1.setplayerlives() collectCoin = 10 lower, upper = fireballfrequency fireballfrequency = (max(0, lower - 20), max(0, upper - 20)) board1.boostfireball() board1.killfireballs() board1.upgradeplayerlevel() self.screen.blit(self.background, self.background.get_rect()) board1.update(self.screen) board1.setPlayerScore( max(0, prevScore + collectCoin * 5 - fireballhitme * 25)) scoreboard1.update(board1.getPlayerScore(), self.screen) scoreboard1.update_lives(self.screen, board1.getPlayerLives()) scoreboard1.update_level(board1.getplayerlevel(), self.screen) pygame.display.flip()
def run_game(): # Provides consistent window positioning. These settings center Pygame window for my computer. os.environ['SDL_VIDEO_WINDOW_POS'] = '60, 35' pygame.init() # Initial Set-up settings = s.Settings() pygame.display.set_caption(settings.get_game_title()) screen = pygame.display.set_mode( (settings.get_screen_width(), settings.get_screen_height())) screen.fill(settings.get_bg_color()) clock = pygame.time.Clock() # Generate Game Objects image_lib = gF.import_image_library() sound_lib = gF.import_sound_library() maze = m.Maze(image_lib, screen, settings) pacman = p.PacMan(maze.pacmanCoordinates, image_lib, screen, settings, sound_lib) pills = maze.pills.copy() large_pills = maze.largePills.copy() blinky = g.Blinky(clock, image_lib, screen, settings, sound_lib, maze.blinkyCoordinates[0], maze.blinkyCoordinates[1], maze.nodes) clyde = g.Clyde(clock, image_lib, screen, settings, sound_lib, maze.clydeCoordinates[0], maze.clydeCoordinates[1], maze.nodes) inky = g.Inky(clock, image_lib, screen, settings, sound_lib, maze.inkyCoordinates[0], maze.inkyCoordinates[1], maze.nodes) pinky = g.Pinky(clock, image_lib, screen, settings, sound_lib, maze.pinkyCoordinates[0], maze.pinkyCoordinates[1], maze.nodes) ghosts = [blinky, clyde, inky, pinky] title_sequence = tS.TitleScreen(clock, pacman.images.copy(), image_lib, screen, settings) title_sequence.refresh_screen() pacman.set_map(maze.get_map(), maze.rowIndex, maze.columnIndex) maze.draw_part_maze() scoreboard = sb.ScoreBoard(maze, screen, settings) timer = 1 # pacTimer timer2 = 0.5 # pillTimer timer3 = 1.5 # ghostTimer delta_t = 0 # Delta to subtract from time reset_flag = False print(reset_flag) gF.start_game(ghosts, large_pills, pacman, pills, sound_lib[0]) pygame.mixer.Sound.play(sound_lib[1], -1) while True: gF.check_events(pacman) pacman.update() reset_flag = gF.check_collisions(ghosts, large_pills, maze, pacman, pills, scoreboard, sound_lib[3]) delta_t, timer, timer2, timer3 = gF.check_time(clock, delta_t, ghosts, large_pills, timer, timer2, timer3, pacman) for pill in large_pills: pill.blit() for ghost in ghosts: # Comment ghost.update out for game to run without ghosts updating. ghost.update() ghost.blit() pacman.blit() pygame.display.flip() if reset_flag: screen.fill(settings.get_bg_color()) pills = maze.pills.copy() large_pills = maze.largePills.copy() maze.draw_part_maze() gF.start_game(ghosts, large_pills, pacman, pills, sound_lib[0]) timer = 1 timer2 = 0.5 timer3 = 1.5 delta_t = 0 reset_flag = False print(reset_flag)
def run_game(): # Provides consistent window positioning. These settings center Pygame window for my computer. os.environ['SDL_VIDEO_WINDOW_POS'] = '60, 35' pygame.init() pygame.mouse.set_visible( False) # Mouse is invisible until Title Sequence finishes animation. settings = se.Settings() screen = pygame.display.set_mode( (settings.get_screen_width(), settings.get_screen_height())) pygame.display.set_caption(settings.get_game_title()) screen.fill(settings.get_bg_color()) title_screen = tS.TitleScreen(screen, settings) title_screen.title_loop() image_library = gF.load_image_library() beep_sounds, sound_library = gF.load_sounds() scoreboard = sb.ScoreBoard(screen, settings, image_library[0], title_screen) alien_list = [] ship_bullet_list = [] alien_bullet_list = [] bunker_list = [] ufo_list = [] gF.create_bunkers(bunker_list, image_library, screen, settings) for bunker in bunker_list: bunker.blit() gF.create_fleet(alien_list, image_library, screen, settings) ship = sh.Ship(image_library, screen, settings, sound_library[2]) counter = 0 beep_counter = 0 time_var = settings.get_time_var() while True: # Now attached to title_screen. If you uncomment this, comment that one out or it's redundant. if settings.get_game_reset(): alien_list = [] bunker_list = [] alien_list, bunker_list = gF.reset_game(alien_list, bunker_list, image_library, scoreboard, screen, settings, ship) ufo_list = [] alien_bullet_list = [] ship_bullet_list = [] gF.check_events(ship_bullet_list, screen, settings, ship, sound_library) ship.update() ufo_list = gF.update_bullets(alien_list, scoreboard, screen, settings, ship_bullet_list, sound_library, ufo_list) ufo_list = gF.update_ufo(ufo_list) beep_counter, counter, time_var = gF.update_aliens( alien_list, beep_counter, beep_sounds, bunker_list, counter, image_library, scoreboard, screen, settings, time_var) if random.randint(1, settings.get_alien_fire_rate()) == 5: gF.create_alien_bullet( alien_list[random.randint(0, len(alien_list) - 1)], alien_bullet_list, screen, settings) a = random.randint(1, 25) if a is 5 and len(ufo_list) is 0: gF.create_ufo(image_library, scoreboard, screen, settings, sound_library, ufo_list) gF.update_alien_bullets(alien_bullet_list, alien_list, screen, settings) alien_bullet_list, ship_bullet_list = gF.check_collisions( alien_bullet_list, alien_list, bunker_list, screen, ship, ship_bullet_list, scoreboard) ship.draw_ship() scoreboard.display_scores() pygame.display.flip()