Exemple #1
0
def CreditsMenu():
    music.load(join(f_music, 'Credits_Music.ogg'))
    music.set_volume(0.5)
    music.play(loops=-1)
    check_credits_menu = True
    coin_animation = 1
    coin_animation_control = 0
    num_image = 1
    y_mov = 0
    background_animation_control = 0
    button_back = Rect(400, 690, 192, 42)
    button_cat_sound = Rect(850, 500, 100, 100)
    while check_credits_menu:

        CLOCK.tick(60)
        mouse_pos = mouse.get_pos()
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                exit()
            if event.type == MOUSEBUTTONDOWN and event.button == 1:
                if button_back.collidepoint(mouse.get_pos()):
                    sfxButtonClick.play()
                    check_credits_menu = False
                if button_cat_sound.collidepoint(mouse.get_pos()):
                    sfxCat.play()

        ButtonsPrint(button_cat_sound, ':3', menuFont)
        SCREEN.blit(scale(load(join(f_backgrounds, f'Credits_{num_image}.png'))
                          .convert_alpha(), (1040, 701)), (0, 80))
        y_move = y_mov % imgCredits.get_rect().height
        SCREEN.blit(imgCredits, (0, (y_move - imgCredits.get_rect().height)))
        if y_move < Height:
            SCREEN.blit(imgCredits, (0, y_move))
        SCREEN.blit(scale(load(join(f_backgrounds, f'CreditsT_{num_image}.png'))
                          .convert_alpha(), (1040, 701)), (0, 80))
        ButtonsPrint(button_back, 'BACK', menuFont)
        SCREEN.blit(imgCursor, (mouse_pos[0], mouse_pos[1]))
        SCREEN.blit(bgArcadeMenu, (0, 0))
        SCREEN.blit(scale(load(join(f_coin, f'Coin_{coin_animation}.png'))
                          .convert_alpha(), (220, 150)), (370, 855))

        y_mov -= 0.75
        coin_animation_control += 0.5
        background_animation_control += 1

        if background_animation_control % 8 == 0:
            num_image += 1
        if num_image == 9:
            num_image = 1

        if coin_animation_control % 6 == 0:
            coin_animation += 1
        if coin_animation > 6:
            coin_animation = 1
            coin_animation_control = 0
        display.update()
    music.stop()
Exemple #2
0
def HowToPlayMenu():
    check_how_to_play = True
    coin_animation = 1
    coin_animation_control = 0
    x_mov = 0
    button_back = Rect(630, 670, 192, 42)
    bonus_1_sound = Rect(210, 580, 50, 70)
    bonus_2_sound = Rect(330, 580, 50, 70)
    bonus_3_sound = Rect(460, 580, 50, 70)
    fuel_sound = Rect(330, 440, 50, 50)

    while check_how_to_play:
        CLOCK.tick(60)
        mouse_pos = mouse.get_pos()
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                exit()
            if event.type == MOUSEBUTTONDOWN and event.button == 1:
                if button_back.collidepoint(mouse.get_pos()):
                    sfxButtonClick.play()
                    check_how_to_play = False
                if bonus_1_sound.collidepoint(mouse.get_pos()):
                    sfxBloodPorky.play()
                if bonus_2_sound.collidepoint(mouse.get_pos()):
                    sfxBloodOldWoman.play()
                if bonus_3_sound.collidepoint(mouse.get_pos()):
                    sfxBloodPolice.play()
                if fuel_sound.collidepoint(mouse.get_pos()):
                    sfxPowerUp.play()

        ButtonsPrint(bonus_1_sound, '1', menuFont)
        ButtonsPrint(bonus_2_sound, '2', menuFont)
        ButtonsPrint(bonus_3_sound, '3', menuFont)
        ButtonsPrint(fuel_sound, 'F', menuFont)
        x_move = x_mov % bgHowToPlay.get_rect().width
        SCREEN.blit(bgHowToPlay, ((x_move - bgHowToPlay.get_rect().width), 70))
        if x_move < Width:
            SCREEN.blit(bgHowToPlay, (x_move, 70))
        SCREEN.blit(imgHowToPlay, (0, 0))
        ButtonsPrint(button_back, 'BACK', menuFont)
        SCREEN.blit(imgCursor, (mouse_pos[0], mouse_pos[1]))
        SCREEN.blit(bgArcadeMenu, (0, 0))
        SCREEN.blit(scale(load(join(f_coin, f'Coin_{coin_animation}.png'))
                          .convert_alpha(), (220, 150)), (370, 855))

        x_mov -= 5
        coin_animation_control += 0.5

        if coin_animation_control % 6 == 0:
            coin_animation += 1
        if coin_animation > 6:
            coin_animation = 1
            coin_animation_control = 0
        display.update()
Exemple #3
0
def GamePause():
    game_pause = True
    while game_pause:
        CLOCK.tick(10)
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                exit()
            if event.type == pygame.KEYDOWN:
                if event.key == pygame.K_SPACE:
                    game_pause = False
                    SCREEN.blit(imgPause, (0, 0))
        SCREEN.blit(bgArcadePause, (0, 0))
        display.update()
Exemple #4
0
def LoadGameScreen():
    music.stop()
    load_bar = 0
    loading = True

    while loading:
        CLOCK.tick(144)
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                exit()

        SCREEN.blit(bgLoading, (-240, 0))
        SCREEN.blit(imgLoad, (0, 0))
        pygame.draw.rect(SCREEN, (35, 100, 198), (185, 552, load_bar, 36))
        SCREEN.blit(bgArcadeGame, (0, 0))
        load_bar += 2
        display.update()
        if load_bar >= 632:
            loading = False
    sleep(2)
Exemple #5
0
def PlayerBusted(background_game1, background_move1, background_game2,
                 background_move2, player, enemies, siren):
    music.stop()
    busted = True
    sfxBusted.play()
    while busted:
        CLOCK.tick(8)
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                exit()
        SCREEN.blit(background_game1, background_move1)
        player.draw(SCREEN)
        enemies.draw(SCREEN)
        SCREEN.blit(background_game2, background_move2)
        siren.draw(SCREEN)
        SCREEN.blit(imgBusted, (0, 0))
        SCREEN.blit(bgArcadeLose, (0, 0))
        display.update()
        sleep(7)
        busted = False
Exemple #6
0
def PlayerCrash(background_game1, background_move1, background_game2,
                background_move2, player, enemies, siren, x, y):
    music.stop()
    crash = True
    coin_animation = 0
    sfxCrash.play()
    while crash:
        CLOCK.tick(8)
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                exit()
        SCREEN.blit(background_game1, background_move1)
        player.draw(SCREEN)
        enemies.draw(SCREEN)
        SCREEN.blit(
            load(join(f_vfx,
                      f'explosion_{coin_animation}.png')).convert_alpha(),
            (x - 30, y - 9))
        SCREEN.blit(background_game2, background_move2)
        siren.draw(SCREEN)
        SCREEN.blit(imgCrash, (0, 0))
        SCREEN.blit(bgArcadeGameOver, (0, 0))
        display.update()
        coin_animation += 1
        if coin_animation == 7:
            crash = False
    player.draw(SCREEN)
    enemies.draw(SCREEN)
    SCREEN.blit(
        load(join(f_vfx, 'explosion_3.png')).convert_alpha(), (x - 30, y - 9))
    SCREEN.blit(background_game2, background_move2)
    siren.draw(SCREEN)
    SCREEN.blit(imgCrash, (0, 0))
    SCREEN.blit(bgArcadeLose, (0, 0))
    display.update()
    sleep(1)
Exemple #7
0
def GameLoop(vehicle_selected):

    fuel = Fuel()
    rails = [156, 233, 313, 390, 470, 546, 627, 703, 783, 861]

    player_group = Group()
    enemies_group = Group()
    score_goal = Group()
    fuel_item = Group()
    bonus_items = Group()
    police_siren_animation = Group()
    kill_bonus_animation = Group()

    player = Player(vehicle_selected)
    player_group.add(player)

    player_score = ScoreGoal()
    score_goal.add(player_score)

    police_siren_images = PoliceSirenAnimation()
    police_siren_animation.add(police_siren_images)

    new_bonus = Bonus()
    bonus_items.add(new_bonus)

    game = True
    music.load(join(f_music, 'Game_Music.ogg'))
    music.set_volume(0.5)
    music.play(loops=-1)
    sfxLowFuel.set_volume(0.05)
    score = 0
    remaining_fuel = 219
    mov_y = 0

    while game:

        CLOCK.tick(FPS)

        if not fuel_item:
            fuel_item.add(fuel)

        if not enemies_group:
            for i in rails:
                enemy_type = Enemy(i)
                enemies_group.add(enemy_type)

        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                exit()
            if event.type == pygame.KEYDOWN:
                if event.key == pygame.K_SPACE:
                    pygame.mixer.music.set_volume(0.2)
                    GamePause()
                    pygame.mixer.music.set_volume(0.7)

        y_move = mov_y % bgGameMap1.get_rect().height
        SCREEN.blit(bgGameMap1, (0, (y_move - bgGameMap1.get_rect().height)))
        if y_move < Height:
            SCREEN.blit(bgGameMap1, (0, y_move))

        player_collision = pygame.sprite.spritecollide(player, enemies_group, False)

        if player_collision:
            sfxLowFuel.stop()
            PlayerCrash(bgGameMap1, (0, (y_move - bgGameMap1.get_rect().height) - 15),
                        bgGameMap2, (0, (y_move - bgGameMap2.get_rect().height) - 15),
                        player_group, enemies_group, police_siren_animation,
                        player.rect.x, player.rect.y)
            GameOver(0, score)
            game = False

        if remaining_fuel <= 0:
            music.stop()
            sfxLowFuel.stop()
            PlayerBusted(bgGameMap1, (0, (y_move - bgGameMap1.get_rect().height) - 15),
                         bgGameMap2, (0, (y_move - bgGameMap2.get_rect().height) - 15),
                         player_group, enemies_group, police_siren_animation)
            GameOver(1, score)
            game = False

        player_group.update()
        fuel_item.update()
        kill_bonus_animation.update()
        bonus_items.update()
        enemies_group.update()
        score_goal.update()
        police_siren_animation.update()

        recharge = pygame.sprite.spritecollide(player, fuel_item, False)
        if recharge:
            sfxLowFuel.stop()
            if vehicle_selected == 1:
                score += 50
            elif vehicle_selected == 2:
                score += 100
            elif vehicle_selected == 3:
                score += 200
            else:
                score += 300
            Fuel.recharge(fuel)
            if remaining_fuel <= 50:
                remaining_fuel += 50
            elif remaining_fuel <= 150:
                remaining_fuel += 25
            else:
                remaining_fuel += 219 - remaining_fuel

        win_score = pygame.sprite.spritecollide(player_score, enemies_group, False)
        if win_score:
            if vehicle_selected == 1:
                score += 1
            elif vehicle_selected == 2:
                score += 1
            elif vehicle_selected == 3:
                score += 2
            else:
                score += 2

        bonus_kill = pygame.sprite.spritecollide(player, bonus_items, False)
        if bonus_kill:
            kill = BloodAnimation(new_bonus.rect.x, new_bonus.rect.y)
            kill_bonus_animation.add(kill)
            sfxLowFuel.stop()
            bonus_type = new_bonus.kill_bonus()
            if bonus_type == 1:
                score += 200
            elif bonus_type == 2:
                score += 100
            else:
                score += 300

        player_group.draw(SCREEN)
        enemies_group.draw(SCREEN)
        fuel_item.draw(SCREEN)
        bonus_items.draw(SCREEN)
        kill_bonus_animation.draw(SCREEN)
        police_siren_animation.draw(SCREEN)
        score_goal.draw(SCREEN)

        y_move = mov_y % bgGameMap2.get_rect().height
        SCREEN.blit(bgGameMap2, (0, (y_move - bgGameMap2.get_rect().height)))

        if y_move < Height:
            SCREEN.blit(bgGameMap2, (0, y_move))

        SCREEN.blit(bgArcadeGame, (0, 0))

        if 1 < remaining_fuel <= 70:
            music.set_volume(0.3)
            sfxLowFuel.play()
            SCREEN.blit(imgLowFuel, (185, 150))
            pygame.draw.rect(SCREEN, (200, 100, 100), (418, 941, remaining_fuel, 15))
        elif 70 < remaining_fuel <= 149:
            music.set_volume(0.5)
            pygame.draw.rect(SCREEN, (252, 209, 42), (418, 941, remaining_fuel, 15))
        else:
            music.set_volume(0.5)
            pygame.draw.rect(SCREEN, (100, 200, 100), (418, 941, remaining_fuel, 15))

        remaining_fuel -= 0.06
        ScorePrint(str(score).zfill(10), 540, 900, (0, 0, 0), 20)
        mov_y += 15
        pygame.display.update()

    return score
Exemple #8
0
def MainMenu():
    button_play = Rect((Width // 4), 200, 192, 42)
    button_high_score = Rect((Width // 4), 305, 470, 42)
    button_how_to_play = Rect((Width // 4), 410, 540, 42)
    button_credits = Rect((Width // 4), 515, 320, 42)
    button_exit = Rect((Width // 4), 620, 175, 42)
    coin_animation = 1
    coin_animation_control = 0
    x_mov = 0
    music.load(join(f_music, 'Menu_Music.ogg'))
    music.set_volume(0.15)
    music.play(loops=-1)

    while game_on:
        CLOCK.tick(Game_Loop.FPS)
        mouse_pos = mouse.get_pos()
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                pygame.quit()
                quit()
            if event.type == MOUSEBUTTONDOWN and event.button == 1:
                if button_play.collidepoint(mouse.get_pos()):
                    sfxButtonClick.play()
                    selection = VehicleSelectMenu()
                    if selection != 0:
                        sleep(1)
                        LoadGameScreen()
                        final_score = Game_Loop.GameLoop(selection)
                        LoadGameScreen()
                        music.load(join(f_music, 'Menu_Music.ogg'))
                        music.set_volume(0.15)
                        music.play(loops=-1)
                        save = open('High_Scores.user', 'a')
                        save.write(str(final_score) + '\n')
                        save.close()
                if button_high_score.collidepoint(mouse.get_pos()):
                    sfxButtonClick.play()
                    HighScoreMenu()
                if button_how_to_play.collidepoint(mouse.get_pos()):
                    sfxButtonClick.play()
                    HowToPlayMenu()
                if button_credits.collidepoint(mouse.get_pos()):
                    sfxButtonClick.play()
                    music.stop()
                    CreditsMenu()
                    music.load(join(f_music, 'Menu_Music.ogg'))
                    music.set_volume(0.15)
                    music.play(loops=-1)
                if button_exit.collidepoint(
                        mouse.get_pos()):
                    sfxButtonClick.play()
                    sleep(1)
                    exit()

        x_move = x_mov % bgMenu.get_rect().width
        SCREEN.blit(bgMenu, ((x_move - bgMenu.get_rect().width), 70))
        if x_move < Width:
            SCREEN.blit(bgMenu, (x_move, 70))

        ButtonsPrint(button_play, 'PLAY', menuFont)
        ButtonsPrint(button_high_score, 'HIGH SCORE', menuFont)
        ButtonsPrint(button_how_to_play, 'HOW TO PLAY', menuFont)
        ButtonsPrint(button_credits, 'CREDITS', menuFont)
        ButtonsPrint(button_exit, 'EXIT', menuFont)

        SCREEN.blit(imgCursor, (mouse_pos[0], mouse_pos[1]))
        SCREEN.blit(bgArcadeMenu, (0, 0))
        SCREEN.blit(scale(load(join(f_coin, f'Coin_{coin_animation}.png'))
                          .convert_alpha(), (220, 150)), (370, 855))

        x_mov -= 5
        coin_animation_control += 0.5

        if coin_animation_control % 6 == 0:
            coin_animation += 1
        if coin_animation > 6:
            coin_animation = 1
            coin_animation_control = 0

        display.update()
Exemple #9
0
def HighScoreMenu():
    scores_file = open('High_Scores.user', 'a')
    ScoreOrder()
    score_1, score_2, score_3 = HighScore()
    check_high_scores = True
    x_mov = 0
    coin_animation = 1
    coin_animation_control = 0
    bongo_cat_animation = 1
    bongo_cat_animation_control = 0
    button_back = Rect(400, 690, 192, 42)
    button_cat_sound = Rect(710, 160, 100, 100)

    while check_high_scores:
        CLOCK.tick(60)
        mouse_pos = mouse.get_pos()
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                exit()
            if event.type == MOUSEBUTTONDOWN and event.button == 1:
                if button_back.collidepoint(mouse.get_pos()):
                    sfxButtonClick.play()
                    check_high_scores = False
                if button_cat_sound.collidepoint(mouse.get_pos()):
                    sfxCat.play()

        ButtonsPrint(button_cat_sound, ':3', menuFont)
        x_move = x_mov % bgHighScores.get_rect().width
        SCREEN.blit(bgHighScores, ((x_move - bgHighScores.get_rect().width), 70))
        if x_move < Width:
            SCREEN.blit(bgHighScores, (x_move, 70))

        SCREEN.blit(imgHighScore, (0, 0))
        ButtonsPrint(button_back, 'BACK', menuFont)
        ScorePrint(score_1.zfill(10), 650, 379, (0, 0, 0), 50)
        ScorePrint(score_1.zfill(10), 650, 375, (255, 255, 255), 50)
        ScorePrint(score_2.zfill(10), 650, 484, (0, 0, 0), 50)
        ScorePrint(score_2.zfill(10), 650, 480, (255, 255, 255), 50)
        ScorePrint(score_3.zfill(10), 650, 584, (0, 0, 0), 50)
        ScorePrint(score_3.zfill(10), 650, 580, (255, 255, 255), 50)
        SCREEN.blit(scale(load(join(f_vfx, f'Bongo_Cat_{bongo_cat_animation}.png'))
                          .convert_alpha(), (198, 198)), (650, 110))
        SCREEN.blit(imgCursor, (mouse_pos[0], mouse_pos[1]))
        SCREEN.blit(bgArcadeMenu, (0, 0))
        SCREEN.blit(scale(load(join(f_coin, f'Coin_{coin_animation}.png'))
                          .convert_alpha(), (220, 150)), (370, 855))

        x_mov -= 5
        coin_animation_control += 0.5
        bongo_cat_animation_control += 2

        if bongo_cat_animation_control % 10 == 0:
            bongo_cat_animation += 1
        if bongo_cat_animation == 21:
            bongo_cat_animation = 1

        if coin_animation_control % 6 == 0:
            coin_animation += 1
        if coin_animation > 6:
            coin_animation = 1
            coin_animation_control = 0
        display.update()
    scores_file.close()
Exemple #10
0
def VehicleSelectMenu():
    selection = True
    vehicle = 0
    coin_animation = 1
    coin_animation_control = 0
    x_mov = 0
    button_back = Rect(400, 690, 192, 42)
    button_car1 = Rect(100, 600, 170, 30)
    button_car2 = Rect(310, 600, 170, 30)
    button_car3 = Rect(520, 600, 170, 30)
    button_car4 = Rect(730, 600, 170, 30)

    while selection:
        CLOCK.tick(60)
        mouse_pos = mouse.get_pos()
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                exit()
            if event.type == MOUSEBUTTONDOWN and event.button == 1:
                if button_back.collidepoint(mouse.get_pos()):
                    sfxButtonClick.play()
                    selection = False
                if button_car1.collidepoint(mouse.get_pos()):
                    sfxButtonClick.play()
                    vehicle = 1
                    selection = False
                if button_car2.collidepoint(mouse.get_pos()):
                    sfxButtonClick.play()
                    vehicle = 2
                    selection = False
                if button_car3.collidepoint(mouse.get_pos()):
                    sfxButtonClick.play()
                    vehicle = 3
                    selection = False
                if button_car4.collidepoint(mouse.get_pos()):
                    sfxButtonClick.play()
                    vehicle = 4
                    selection = False

        x_move = x_mov % bgVehicleSelection.get_rect().width
        SCREEN.blit(bgVehicleSelection,
                    ((x_move - bgVehicleSelection.get_rect().width), 72))
        if x_move < Width:
            SCREEN.blit(bgVehicleSelection, (x_move, 72))
        SCREEN.blit(imgCars, (0, 0))
        ButtonsPrint(button_back, 'BACK', menuFont)
        ButtonsPrint(button_car1, 'SELECT', carFont)
        ButtonsPrint(button_car2, 'SELECT', carFont)
        ButtonsPrint(button_car3, 'SELECT', carFont)
        ButtonsPrint(button_car4, 'SELECT', carFont)
        SCREEN.blit(imgCursor, (mouse_pos[0], mouse_pos[1]))
        SCREEN.blit(bgArcadeMenu, (0, 0))
        SCREEN.blit(scale(load(join(f_coin, f'Coin_{coin_animation}.png'))
                          .convert_alpha(), (220, 150)), (370, 855))

        x_mov -= 5
        coin_animation_control += 1

        if coin_animation_control % 6 == 0:
            coin_animation += 1
        if coin_animation > 6:
            coin_animation = 1
            coin_animation_control = 0
        display.update()
    return vehicle
Exemple #11
0
def GameOver(game_event, score):
    game_over_animation = True
    game_event = game_event
    music.load(join(f_music, 'Game_Over_Music.ogg'))
    music.play(loops=-1)
    music.set_volume(0.7)
    police_animation = 1
    fire_smoke_animation = 1
    mov_x = 0
    while game_over_animation:
        CLOCK.tick(8)
        for game_event in pygame.event.get():
            if game_event.type == pygame.QUIT:
                exit()
            if game_event.type == pygame.KEYDOWN:
                if game_event.key == pygame.K_SPACE:
                    game_over_animation = False

        x_move = mov_x % bgGameOver.get_rect().width
        SCREEN.blit(bgGameOver, ((x_move - bgGameOver.get_rect().width), 70))

        if x_move < Width:
            SCREEN.blit(bgGameOver, (x_move, 70))

        if game_event == 1:
            SCREEN.blit(imgGameOverPolice, (0, 0))
            SCREEN.blit(
                load(
                    join(f_gameOver, f'PoliceCar_01_{fire_smoke_animation}.png'
                         )).convert_alpha(), (50, 460))
            SCREEN.blit(
                load(
                    join(f_gameOver, f'PoliceCar_02_{fire_smoke_animation}.png'
                         )).convert_alpha(), (590, 450))
            SCREEN.blit(
                load(
                    join(f_gameOver,
                         f'Policeman_{police_animation}.png')).convert_alpha(),
                (475, 510))
            SCREEN.blit(
                load(join(f_gameOver,
                          f'Men_{police_animation}.png')).convert_alpha(),
                (450, 535))
        else:
            SCREEN.blit(imgGameOverCrash, (0, 0))
            SCREEN.blit(
                load(join(
                    f_vfx,
                    f'Fire_01_{fire_smoke_animation}.png')).convert_alpha(),
                (580, 400))
            SCREEN.blit(
                load(
                    join(f_vfx,
                         f'Smoke_{fire_smoke_animation}.png')).convert_alpha(),
                (510, 450))
            SCREEN.blit(
                load(join(f_vfx,
                          f'Fire_02_{police_animation}.png')).convert_alpha(),
                (415, 570))

        ScorePrint(str(score).zfill(10), 720, 180, (236, 219, 83), 30)
        SCREEN.blit(bgArcadeGameOver, (0, 0))
        police_animation += 1
        fire_smoke_animation += 1
        mov_x += 15
        if police_animation == 5:
            police_animation = 1
        if fire_smoke_animation == 9:
            fire_smoke_animation = 1
        display.update()
    SCREEN.fill((0, 0, 0))