Beispiel #1
0
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)
Beispiel #2
0
    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)
Beispiel #3
0
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
Beispiel #4
0
    'left': pygame.image.load('Chicken.png'),
    'standingleft': pygame.image.load('Chicken.png')
}
classroom = pygame.image.load(os.path.join('Stuff', 'Classroom.png'))
classroom = pygame.transform.scale(classroom,
                                   (Sprite.DISPLAY_X, Sprite.DISPLAY_Y))

classroomwall = pygame.image.load(os.path.join('Stuff', 'Classroom Wall.png'))
wall = classroomwall.get_rect()
scaley = Sprite.DISPLAY_X / wall.width
classroomwall = pygame.transform.scale(
    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)


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
Beispiel #5
0
    'left': pygame.image.load('Chicken.png'),
    'standingleft': pygame.image.load('Chicken.png')
}
classroom = pygame.image.load(os.path.join('Stuff', 'Classroom.png'))
classroom = pygame.transform.scale(classroom,
                                   (Sprite.DISPLAY_X, Sprite.DISPLAY_Y))

classroomwall = pygame.image.load(os.path.join('Stuff', 'Classroom Wall.png'))
wall = classroomwall.get_rect()
scaley = Sprite.DISPLAY_X / wall.width
classroomwall = pygame.transform.scale(
    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:
Beispiel #6
0
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")