Example #1
0
class GameEngine:
    def __init__(self):
        self.player = Character("test", main_batch, foreground)
        self.background = Background(self.player, main_batch, background)
            
    def draw(self, fps=0):
        self.background.update()
        self.player.apply_forces()
Example #2
0
                type = random.randint(4, 5)
            elif level == 5:
                type = random.randint(1, 5)

            x = random.randint(10, WIDTH - 100)
            e = Enemy(x, -150, type)
            enemy_group.add(e)
            start_time = current_time

        if plane_destroy_count:
            if plane_destroy_count % 5 == 0 and level < 5:
                level += 1
                plane_destroy_count = 0

        p.fuel -= 0.05
        bg.update(1)
        win.blit(clouds_img, (0, 70))

        p.update(moving_left, moving_right, explosion_group)
        p.draw(win)

        player_bullet_group.update()
        player_bullet_group.draw(win)
        enemy_bullet_group.update()
        enemy_bullet_group.draw(win)
        explosion_group.update()
        explosion_group.draw(win)
        fuel_group.update()
        fuel_group.draw(win)
        powerup_group.update()
        powerup_group.draw(win)
Example #3
0
    if any(pygame.mouse.get_pressed()):
        pos = pygame.mouse.get_pos()

    if main_menu:
        win.blit(menu_img, (xoffset, yoffset),
                 (200, 0, xoffset + WIDTH, HEIGHT))
        draw.border()

        win.blit(start_btn, start_rect)
        if pos and start_rect.collidepoint(pos):
            main_menu = False
            bg.move = False

    if restart_menu:
        bg.update()
        draw.bottom_black_bar()
        draw.top_black_bar()
        draw.border()

        draw.score_box(coin_img, car_dodged_img, speedometer, coins_collected,
                       car_dodged, speed, score_font)
        if p.rect.bottom <= yoffset + HEIGHT:
            pos = None
            p.rect.y += 10
            p.update(pos, p_speed)
            enemy_group.update(10)
            roadblock_group.update(10)
        else:
            p.update(pos, 0)
            enemy_group.update(0)