def calculator(): if Var.set_up_calculator == True: global calcy, calcwait_time, calctime_elapsed Var.mouseDOWNPOS = (0, 0) Var.mouseDOWN = False calcy = 300 calcwait_time = 10 calctime_elapsed = 0 Var.set_up_calculator = False Sprite.DISPLAY.blit(menu, (0,0)) Sprite.DISPLAY.blit(calc, (300,calcy)) calc_rect.topleft = (300,calcy) if calcy <= 30: calcy = 30 calc_screen() #Sprite.DISPLAY.blit(text_box, (0, int(4*Sprite.DISPLAY_Y/5))) #events = pygame.event.get() #Input2.update(events) Sprite.DISPLAY.blit(Input2.get_surface(), (450, 310)) Calculus.calc_question() Sprite.DISPLAY.blit(Box, (0,-35)) show_text("NOTE: log is in base e.", (40, 140), 20, (0, 0, 0)) show_text("Use asin for arcsin, etc..", (40, 170), 20, (0, 0, 0)) show_text("Use ** as exponent.", (40, 200), 20, (0, 0, 0)) show_text("Must * coefficents to x.", (40, 230), 20, (0, 0, 0)) show_text("(4x is illegal. 4*x is okay.)", (40, 260), 20, (0, 0, 0)) show_text("Use exp(x) for e**x.", (40, 290), 20, (0, 0, 0)) show_text("Everything in respect to x variable.", (40, 310), 15, (0, 0, 0)) show_text("Other letters may be used as constants.", (40, 330), 15, (0, 0, 0)) space = 10 show_text("Will freeze if too hard.", (40, 350 + space), 20, (0, 0, 0)) show_text("log in base 10 unavailable", (40, 380 + space), 20, (0, 0, 0)) show_text("Click elsewhere to return.", (40, 410 + space), 20, (0, 0, 0)) else: calcy -= 8 events = pygame.event.get() Input2.update(events) calctime_elapsed += 1 if calctime_elapsed > calcwait_time: if Var.mouseDOWN == True: if not calc_rect.collidepoint(Var.mouseDOWNPOS): Var.set_up_menu = True Var.calculator = False Var.menu = True
def shoot_zombies(): 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) for zombie in range(Var.screenZombies - (len(Sprite.Zombies))): zomx = random.randint(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)
def calculator(): if Var.set_up_calculator == True: global calcy calcy = 300 Var.set_up_calculator = False Sprite.DISPLAY.blit(menu, (0, 0)) Sprite.DISPLAY.blit(calc, (300, calcy)) if calcy <= 30: calcy = 30 calc_screen() #Sprite.DISPLAY.blit(text_box, (0, int(4*Sprite.DISPLAY_Y/5))) events = pygame.event.get() Input2.update(events) Sprite.DISPLAY.blit(Input2.get_surface(), (450, 310)) Calculus.calc_question() else: calcy -= 5
if keys[pygame.K_LSHIFT]: Var.keyLSHIFT = True if not keys[pygame.K_LSHIFT]: Var.keyLSHIFT = False RUNNING = True while RUNNING == True: variables() Var.mousePOS = pygame.mouse.get_pos() Sprite.DISPLAY.fill((60,70,80)) Sprite.objList.update() Sprite.Player.update() # Note, please change layers depending on y value: https://www.reddit.com/r/pygame/comments/3de4ng/challenge_drawing_in_the_right_order/ # Answer: https://github.com/iminurnamez/draw-order-challenge/commit/387da00cf21e63d0cddee61737df3edd91aa59b4 pygame.draw.rect(Sprite.DISPLAY, (200, 10, 15), Sprite.Player.colliderect, 2) Sprite.drawSprites(Sprite.spritesList) Thing.update_input() Calculus.show_question() pygame.display.update() fpsClock.tick(FPS)
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 = 30 Var.Ammo = 8 Var.screenZombies = 1 Var.totalKilled = 0 Var.addZombie = 1 Var.totalSolved = 0 time_elapsed = 0 wait_time = 250 total_time_elapsed = 0 Sprite.objList.add(classroomwall) Sprite.spritesList.add(classroomwall) Var.set_up_class = False Sprite.DISPLAY.blit(classroom, (0, 0)) Sprite.objList.update() Sprite.Bullets.update() Sprite.Player.update() Sprite.Zombies.update() Sprite.drawSprites(Sprite.spritesList) 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, 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
def shoot_zombies(): global time_elapsed, wait_time #Sprite.DISPLAY.fill((100,120,80)) Sprite.DISPLAY.blit(classroom, (0, 0)) Sprite.objList.update() Sprite.Bullets.update() Sprite.Player.update() Sprite.Zombies.update() Sprite.drawSprites(Sprite.spritesList) 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 if time_elapsed > wait_time: Var.addZombie = 1 time_elapsed = 0 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 print(Var.totalKilled) 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, 2, (zomx, zomy), False) Sprite.Zombies.add(zombie) Sprite.spritesList.add(zombie) Var.addZombie = 0 if Var.Health == 0: # Game over print("You died")