예제 #1
0
def draw():
    global font, gold
    clear_canvas()
    for game_object in game_world.all_objects():
        game_object.draw()
    for i in range(dragon.life):
        life.draw(i * 40 + 20, 580, 40, 40)
    font.draw(830, 580, '%d' % first_main_state.dragon.gold, (255, 255, 255))
    update_canvas()
예제 #2
0
def update():
    global is_magician_spawn, fire, bananas, turnips, watermelons, main_sound, boss_sound
    for game_object in game_world.all_objects():
        game_object.update()

    if dragon.is_fall:
        if bottom_collide(dragon, background, 12):
            dragon.stop()
        else:
            if not bottom_collide(dragon, background, 12):
                dragon.cancel_stop()

    for tadpole in tadpoles:
        if bottom_collide(tadpole, background, 12):
            tadpole.is_fall = False
        else:
            tadpole.is_fall = True
        if collide(dragon, tadpole):
            if not tadpole.is_beaten:
                if not dragon.is_beaten:
                    if dragon.life >= 0:
                        dragon.sound_beat()
                        dragon.life -= 1
                    dragon.is_beaten = True
                    dragon.invincible_start_time = get_time()
            else:
                if not tadpole.is_dead:
                    dragon.sound_kill_monster()
                    first_main_state.dragon.gold += 100
                    tadpole.is_dead = True
                    fruit_random_spawn_percent = random.randint(1, 200)
                    if fruit_random_spawn_percent <= 60:
                        bananas = Banana(tadpole.x, tadpole.y)
                        game_world.add_object(bananas, 6)
                        bananas.spawn_start_time = get_time()
                    elif fruit_random_spawn_percent <= 110:
                        turnips = Turnip(tadpole.x, tadpole.y)
                        game_world.add_object(turnips, 6)
                        turnips.spawn_start_time = get_time()
                    elif fruit_random_spawn_percent <= 140:
                        watermelons = Watermelon(tadpole.x, tadpole.y)
                        game_world.add_object(watermelons, 6)
                        watermelons.spawn_start_time = get_time()
                    tadpole.check_dead_motion_time = get_time()
                    tadpole.check_dead_motion_time = get_time()

    for tadpole in tadpoles:
        if tadpole.check_dead_motion_end_time > 1:
            game_world.remove_object(tadpole)

    if game_world.objects[6]:
        for i in game_world.objects[6]:
            if i.spawn_check_time > 1:
                i.is_spawn = True
        for i in game_world.objects[6]:
            if i.is_spawn:
                if collide(dragon, i):
                    dragon.sound_eat_fruit()
                    if i.number == 1:
                        first_main_state.dragon.gold += 50
                    elif i.number == 2:
                        first_main_state.dragon.gold += 100
                    else:
                        first_main_state.dragon.gold += 200
                    game_world.remove_object(i)

    if not game_world.objects[1]:
        if not is_magician_spawn:
            del main_sound
            boss_sound.repeat_play()
            game_world.add_object(magician, 3)
            is_magician_spawn = True

    if game_world.objects[4]:
        for tadpole in tadpoles:
            for i in game_world.objects[4]:
                if collide(i, tadpole):
                    if not tadpole.is_beaten:
                        game_world.remove_object(i)
                        tadpole.is_beaten = True

    # dragon -> bubble
    if game_world.objects[3]:
        if game_world.objects[4]:
            for i in game_world.objects[4]:
                if collide(i, magician):
                    game_world.remove_object(i)
                    if magician.hp >= 0:
                        magician.hp -= 1

                    else:
                        if not magician.is_lock:
                            magician.is_lock = True

        if magician.hp == 16:
            magician.second_phase_move_time_start = get_time()

        if not magician.is_lock:
            if magician.check_attack_end_time > (0.5 - (magician.phase * 0.1)):
                fire = Fire(magician.x, magician.y, magician.phase, magician.fire_number)
                game_world.add_object(fire, 5)
                magician.fire_number = (magician.fire_number + 1) % 16
                magician.check_attack_start_time = get_time()

        if collide(dragon, magician):
            if not magician.is_lock:
                if not dragon.is_beaten:
                    if dragon.life >= 0:
                        dragon.sound_beat()
                        dragon.life -= 1
                    dragon.is_beaten = True
                    dragon.invincible_start_time = get_time()
            else:
                if not magician.is_dead:
                    dragon.sound_kill_monster()
                    first_main_state.dragon.gold += 700
                    magician.check_dead_motion_start_time = get_time()
                    magician.is_dead = True

        if magician.check_dead_motion_end_time > 1:
            game_world.remove_object(magician)
            game_framework.change_state(second_store_state)

    if not magician.is_dead:
        if fire:
            for i in game_world.objects[5]:
                if collide(dragon, i):
                    if not dragon.is_beaten:
                        if dragon.life >= 0:
                            dragon.sound_beat()
                            dragon.life -= 1
                        dragon.is_beaten = True
                        dragon.invincible_start_time = get_time()
                        game_world.remove_object(i)
                else:
                    if i.x < 0 or i.x > 960 or i.y < 0 or i.y > 550:
                        game_world.remove_object(i)

    if dragon.life < 0:
        game_framework.change_state(game_over_state)
예제 #3
0
def update():
    global is_redpole_spawn, lightning, bananas, turnips, watermelons, water, main_sound, boss_sound
    for game_object in game_world.all_objects():
        game_object.update()

    if dragon.y <= 26:
        dragon.y = 540
    if dragon.is_fall:
        if bottom_collide(dragon, background, 14):
            dragon.stop()
        else:
            if not bottom_collide(dragon, background, 14):
                dragon.cancel_stop()

    for pulpul in pulpuls:
        if pulpul.y <= 26:
            pulpul.y = 540

        if bottom_collide(pulpul, background, 14):
            pulpul.is_fall = False
        else:
            pulpul.is_fall = True
        if collide(dragon, pulpul):
            if not pulpul.is_beaten:
                if not dragon.is_beaten:
                    if dragon.life >= 0:
                        dragon.sound_beat()
                        dragon.life -= 1

                    dragon.is_beaten = True
                    dragon.invincible_start_time = get_time()
            else:
                if not pulpul.is_dead:
                    dragon.sound_kill_monster()
                    first_main_state.dragon.gold += 100
                    pulpul.is_dead = True
                    fruit_random_spawn_percent = random.randint(1, 200)
                    if fruit_random_spawn_percent <= 60:
                        bananas = Banana(pulpul.x, pulpul.y)
                        game_world.add_object(bananas, 6)
                        bananas.spawn_start_time = get_time()
                    elif fruit_random_spawn_percent <= 110:
                        turnips = Turnip(pulpul.x, pulpul.y)
                        game_world.add_object(turnips, 6)
                        turnips.spawn_start_time = get_time()
                    elif fruit_random_spawn_percent <= 140:
                        watermelons = Watermelon(pulpul.x, pulpul.y)
                        game_world.add_object(watermelons, 6)
                        watermelons.spawn_start_time = get_time()
                    pulpul.check_dead_motion_time = get_time()
                    pulpul.check_dead_motion_time = get_time()

    for pulpul in pulpuls:
        if pulpul.check_dead_motion_end_time > 1:
            game_world.remove_object(pulpul)

    if game_world.objects[6]:
        for i in game_world.objects[6]:
            if i.spawn_check_time > 1:
                i.is_spawn = True
        for i in game_world.objects[6]:
            if i.is_spawn:
                if collide(dragon, i):
                    dragon.sound_eat_fruit()
                    if i.number == 1:
                        dragon.gold += 50
                    elif i.number == 2:
                        dragon.gold += 100
                    else:
                        dragon.gold += 200
                    game_world.remove_object(i)

    if not game_world.objects[1]:
        if not is_redpole_spawn:
            del main_sound
            boss_sound.repeat_play()
            game_world.add_object(redpole, 3)
            is_redpole_spawn = True

    if game_world.objects[4]:
        for pulpul in pulpuls:
            for i in game_world.objects[4]:
                if collide(i, pulpul):
                    if not pulpul.is_beaten:
                        game_world.remove_object(i)
                        pulpul.is_beaten = True

    # dragon -> bubble
    if game_world.objects[3]:
        if game_world.objects[4]:
            for i in game_world.objects[4]:
                if collide(i, redpole):
                    game_world.remove_object(i)
                    if redpole.hp >= 0:
                        redpole.hp -= 1
                    else:
                        if not redpole.is_lock:
                            redpole.is_lock = True

        if not redpole.is_lock:
            if redpole.check_attack_end_time > (0.5 - (redpole.phase * 0.1)):
                lightning = Lightning(redpole.x, redpole.y, redpole.phase,
                                      redpole.lightning_number)
                game_world.add_object(lightning, 5)
                redpole.lightning_number = (redpole.lightning_number + 1) % 16
                redpole.check_attack_start_time = get_time()

            if redpole.phase == 3:
                if redpole.check_second_attack_end_time > (
                        0.5 - (redpole.phase * 0.1)):
                    water = Water(redpole.x, redpole.y, redpole.phase,
                                  (redpole.lightning_number + 8) % 16)
                    game_world.add_object(water, 7)
                    redpole.check_second_attack_start_time = get_time()

        if collide(dragon, redpole):
            if not redpole.is_lock:
                if not dragon.is_beaten:
                    if dragon.life >= 0:
                        dragon.sound_beat()
                        dragon.life -= 1
                    dragon.is_beaten = True
                    dragon.invincible_start_time = get_time()
            else:
                if not redpole.is_dead:
                    dragon.sound_kill_monster()
                    first_main_state.dragon.gold += 900
                    redpole.check_dead_motion_start_time = get_time()
                    redpole.is_dead = True

        if redpole.check_dead_motion_end_time > 1:
            game_world.remove_object(redpole)
            game_framework.change_state(end_state)

    if not redpole.is_dead:
        if lightning:
            for i in game_world.objects[5]:
                if collide(dragon, i):
                    if not dragon.is_beaten:
                        if dragon.life >= 0:
                            dragon.sound_beat()
                            dragon.life -= 1
                        dragon.is_beaten = True
                        dragon.invincible_start_time = get_time()
                        game_world.remove_object(i)
                else:
                    if i.x < 0 or i.x > 960 or i.y < 0 or i.y > 550:
                        game_world.remove_object(i)

        if water:
            for i in game_world.objects[7]:
                if collide(dragon, i):
                    if not dragon.is_beaten:
                        if dragon.life >= 0:
                            dragon.life -= 1
                        dragon.is_beaten = True
                        dragon.invincible_start_time = get_time()
                        game_world.remove_object(i)
                else:
                    if i.x < 0 or i.x > 960 or i.y < 0 or i.y > 550:
                        game_world.remove_object(i)

    if dragon.life < 0:
        game_framework.change_state(game_over_state)
예제 #4
0
def update():
    global is_drunk_spawn, gold, damage, bottle, bananas, turnips, watermelons, walkers, main_sound, boss_sound
    for game_object in game_world.all_objects():
        game_object.update()

    if dragon.is_fall:
        if bottom_collide(dragon, background, 8):
            dragon.stop()
        else:
            if not bottom_collide(dragon, background, 8):
                dragon.cancel_stop()

    for walker in walkers:
        fruit_random_spawn_percent = random.randint(1, 200)
        if bottom_collide(walker, background, 8):
            walker.is_fall = False
        else:
            walker.is_fall = True

        if collide(dragon, walker):
            if not walker.is_beaten:
                if not dragon.is_beaten:
                    if dragon.life >= 0:
                        dragon.life -= 1
                        dragon.sound_beat()
                    dragon.is_beaten = True
                    dragon.invincible_start_time = get_time()
            else:
                if not walker.is_dead:
                    dragon.sound_kill_monster()
                    walker.is_dead = True
                    dragon.gold += 100
                    fruit_random_spawn_percent = random.randint(1, 200)
                    if fruit_random_spawn_percent <= 60:
                        bananas = Banana(walker.x, walker.y)
                        game_world.add_object(bananas, 6)
                        bananas.spawn_start_time = get_time()
                    elif fruit_random_spawn_percent <= 110:
                        turnips = Turnip(walker.x, walker.y)
                        game_world.add_object(turnips, 6)
                        turnips.spawn_start_time = get_time()
                    elif fruit_random_spawn_percent <= 140:
                        watermelons = Watermelon(walker.x, walker.y)
                        game_world.add_object(watermelons, 6)
                        watermelons.spawn_start_time = get_time()
                    walker.check_dead_motion_time = get_time()

    for walker in walkers:
        if walker.check_dead_motion_end_time > 1:
            game_world.remove_object(walker)

    if game_world.objects[6]:
        for i in game_world.objects[6]:
            if i.spawn_check_time > 1:
                i.is_spawn = True
        for i in game_world.objects[6]:
            if i.is_spawn:
                if collide(dragon, i):
                    dragon.sound_eat_fruit()
                    if i.number == 1:
                        dragon.gold += 50
                    elif i.number == 2:
                        dragon.gold += 100
                    else:
                        dragon.gold += 200
                    game_world.remove_object(i)

    if not game_world.objects[1]:
        if not is_drunk_spawn:
            game_world.add_object(drunk, 3)
            del main_sound
            boss_sound.repeat_play()
            drunk.phase_start_time = get_time()
            is_drunk_spawn = True

    if game_world.objects[4]:
        for walker in walkers:
            for i in game_world.objects[4]:
                if collide(i, walker):
                    if not walker.is_beaten:
                        drunk.hp -= 1
                        drunk.is_beaten = True
                        game_world.remove_object(i)
                        walker.is_beaten = True

    # dragon -> bubble
    if game_world.objects[3]:
        if game_world.objects[4]:
            for i in game_world.objects[4]:
                if collide(i, drunk):
                    game_world.remove_object(i)
                    if drunk.hp > 0:
                        drunk.hp -= 1

                    else:
                        if not drunk.is_lock:
                            drunk.is_lock = True

        if not drunk.is_lock:
            if drunk.check_attack_end_time > (0.5 - (drunk.phase * 0.1)):
                bottle = Bottle(drunk.x, drunk.y, drunk.phase,
                                drunk.bottle_number)
                game_world.add_object(bottle, 5)
                drunk.bottle_number = (drunk.bottle_number + 1) % 16
                drunk.check_attack_start_time = get_time()

        if collide(dragon, drunk):
            if not drunk.is_lock:
                if not dragon.is_beaten:
                    if dragon.life >= 0:
                        dragon.sound_beat()
                        dragon.life -= 1
                    dragon.is_beaten = True
                    dragon.invincible_start_time = get_time()
            else:
                if not drunk.is_dead:
                    dragon.sound_kill_monster()
                    dragon.gold += 500
                    drunk.check_dead_motion_start_time = get_time()
                    drunk.is_dead = True

        if drunk.check_dead_motion_end_time > 1:
            game_world.remove_object(drunk)
            game_world.clear()
            game_framework.change_state(store_state)

    if not drunk.is_dead:
        if bottle:
            for i in game_world.objects[5]:
                if collide(dragon, i):
                    if not dragon.is_beaten:
                        if dragon.life >= 0:
                            dragon.sound_beat()
                            dragon.life -= 1
                        dragon.is_beaten = True
                        dragon.invincible_start_time = get_time()
                        game_world.remove_object(i)
                else:
                    if i.x < 0 or i.x > 960 or i.y < 0 or i.y > 550:
                        game_world.remove_object(i)

    if dragon.life < 0:
        game_framework.change_state(game_over_state)