def shoot_zombies(): if Var.set_up_class == True: global time_elapsed, wait_time, total_time_elapsed for zombie in Sprite.Zombies: zombie.kill() Var.Answer = None Var.Health = 20 Var.Ammo = 5 Var.screenZombies = 1 Var.totalKilled = 0 Var.addZombie = 1 Var.totalSolved = 0 Var.mouseDOWNPOS = (0, 0) Var.mouseDOWN = False Sprite.Player.posx = int(Sprite.DISPLAY_X / 2 - 8) #Sprite.Player.posy = int(Sprite.DISPLAY_Y/2) Sprite.Player.posy = 120 Sprite.Player.wasdirection = 'down' time_elapsed = 0 wait_time = 250 total_time_elapsed = 0 Sprite.objList.add(classroomwall) Sprite.spritesList.add(classroomwall) Sprite.objList.add(plant) Sprite.spritesList.add(plant) for pos in range(len(desk_positions)): table = Sprite.Object(desk, 2 / 3, desk_positions[pos], False) Sprite.objList.add(table) Sprite.spritesList.add(table) Var.set_up_class = False Sprite.DISPLAY.blit(classroom, (0, 0)) Sprite.objList.update() Sprite.Player.update() Sprite.Zombies.update() Sprite.drawSprites(Sprite.spritesList) Sprite.Bullets.update() update_input() Calculus.show_question() if Var.mouseDOWN and Var.Ammo != 0: Ammo = Sprite.Ammo(Chicken, 2, (Sprite.Player.posx, Sprite.Player.posy), False) Sprite.Bullets.add(Ammo) for zombie in Sprite.Zombies: zombie.moveto(1, 1, [(Sprite.Player.posx, Sprite.Player.posy)], False) '''# modulos so that zombies come in "waves". OR escalating difficulty with ugly conditionals # addZombies = Var.totalKilled%5 # screenZombies = Var.screenZombies + addZombies''' '''for zombie in range(Var.screenZombies - (len(Sprite.Zombies))): #zomx = random.randint(0, Sprite.DISPLAY_X) zomx = random.choice([0, Sprite.DISPLAY_X]) zomy = random.randint(0, Sprite.DISPLAY_Y) zombie = Sprite.Zombie(Images.Zombie_Image, 2, (zomx, zomy), False) Sprite.Zombies.add(zombie) Sprite.spritesList.add(zombie) # change this for time based instead if Var.totalKilled == 3: Var.screenZombies = 2 elif Var.totalKilled == 5: Var.screenZombies = 3 elif Var.totalKilled == 10: Var.screenZombies = 4 elif Var.totalKilled == 15: Var.screenZombies = 5 ''' # revamped for time based: Var.addZombie = 1 if add a zombie; Var.addZombie = 0 if NOT add time_elapsed += 1 total_time_elapsed += 1 if time_elapsed > wait_time: Var.addZombie = 1 time_elapsed = 0 if total_time_elapsed >= 1500: wait_time = 155 elif total_time_elapsed >= 1300: wait_time = 160 elif total_time_elapsed >= 1100: wait_time = 180 elif total_time_elapsed >= 800: wait_time = 200 elif total_time_elapsed >= 500: wait_time = 225 '''if Var.totalKilled == 4: wait_time = 225 elif Var.totalKilled == 8: wait_time = 200 elif Var.totalKilled == 12: wait_time = 180 elif Var.totalKilled == 15: wait_time = 160''' for zombie in range(Var.addZombie): #zomx = random.randint(0, Sprite.DISPLAY_X) zomx = random.choice([0, Sprite.DISPLAY_X]) zomy = random.randint(0, Sprite.DISPLAY_Y) zombie = Sprite.Zombie(Images.Zombie_Image, 5 / 2, (zomx, zomy), False) Sprite.Zombies.add(zombie) Sprite.spritesList.add(zombie) Var.addZombie = 0 if Var.Health <= 0: # Game over Var.in_class = False Var.you_died = True Var.set_up_died = True
classroomwall, (Sprite.DISPLAY_X, int(wall.height * scaley))) classroomwall = pygame.transform.flip(classroomwall, True, False) ClassWall = Images.autodict(classroomwall, classroomwall, classroomwall, classroomwall, classroomwall, classroomwall) classroomwall = Sprite.BigObject(ClassWall, 1, (0, 0), False) desk = pygame.image.load(os.path.join('Stuff', 'Desk with Chair.png')) desk = Images.autodict(desk, desk, desk, desk, desk, desk) #desk = Sprite.Object(desk, 2/3, (820, 350), False) desk_positions = [(850, 500), (850, 350), (850, 200), (250, 500), (250, 350), (250, 200), (50, 500), (50, 350), (50, 200), (650, 500), (650, 350), (650, 200), (450, 500), (450, 350), (450, 200)] plant = pygame.image.load(os.path.join('Stuff', 'Plant.png')) plant = Images.autodict(plant, plant, plant, plant, plant, plant) plant = Sprite.Object(plant, 1 / 2, (630, 60), False) def shoot_zombies(): if Var.set_up_class == True: global time_elapsed, wait_time, total_time_elapsed for zombie in Sprite.Zombies: zombie.kill() Var.Answer = None Var.Health = 20 Var.Ammo = 5 Var.screenZombies = 1 Var.totalKilled = 0 Var.addZombie = 1