- 10, self.width * (self.health / 100), 
pip install pygame
import pygame
import sys
from player import Player
from enemy import Enemy

# Initialisation de Pygame
pygame.init()

# Paramètres de la fenêtre
WIDTH, HEIGHT = 800, 600
WIN = pygame.display.set_mode((WIDTH, HEIGHT))
pygame.display.set_caption("Mini Brawl Stars")

# Couleurs
WHITE = (255, 255, 255)

# FPS
FPS = 60

# Fonction principale du jeu
def main():
    clock = pygame.time.Clock()
    player = Player(WIDTH//2, HEIGHT//2)
    enemy = Enemy(WIDTH//4, HEIGHT//4)

    run = True
    while run:
        clock.tick(FPS)
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                run = False

        keys = pygame.key.get_pressed()
        player.move(keys)

        WIN.fill(WHITE)
        player.draw(WIN)
        enemy.draw(WIN)
        pygame.display.update()

    pygame.quit()
    sys.exit()

if __name__ == "__main__":
    main()
import pygame

# Classe Player
class Player:
    def __init__(self, x, y):
        self.x = x
        self.y = y
        self.width = 50
        self.height = 50
        self.color = (0, 0, 255)
        self.vel = 5

    def draw(self, win):
        pygame.draw.rect(win, self.color, (self.x, self.y, self.width, self.height))

    def move(self, keys):
        if keys[pygame.K_LEFT] and self.x - self.vel > 0:  # LEFT
            self.x -= self.vel
        if keys[pygame.K_RIGHT] and self.x + self.vel + self.width < 800:  # RIGHT
            self.x += self.vel
        if keys[pygame.K_UP] and self.y - self.vel > 0:  # UP
            self.y -= self.vel
        if keys[pygame.K_DOWN] and self.y + self.vel + self.height < 600:  # DOWN
            self.y += self.vel
import pygame

# Classe Enemy
class Enemy:
    def __init__(self, x, y):
        self.x = x
        self.y = y
        self.width = 50
        self.height = 50
        self.color = (255, 0, 0)

    def draw(self, win):
        pygame.draw.rect(win, self.color, (self.x, self.y, self.width, self.height))
# Fichier pour stocker les paramètres du jeu

# Taille de la fenêtre
WIDTH, HEIGHT = 800, 600

# Couleurs
WHITE = (255, 255, 255)
import pygame
import sys
from player import Player
from enemy import Enemy
from projectile import Projectile

# Initialisation de Pygame
pygame.init()

# Paramètres de la fenêtre
WIDTH, HEIGHT = 800, 600
WIN = pygame.display.set_mode((WIDTH, HEIGHT))
pygame.display.set_caption("Mini Brawl Stars")

# Couleurs
WHITE = (255, 255, 255)

# FPS
FPS = 60

# Fonction principale du jeu
def main():
    clock = pygame.time.Clock()
    player = Player(WIDTH // 2, HEIGHT // 2)
    enemies = [Enemy(WIDTH // 4, HEIGHT // 4)]
    projectiles = []
    score = 0

    font = pygame.font.Font(None, 36)

    run = True
    while run:
        clock.tick(FPS)
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                run = False
            if event.type == pygame.KEYDOWN:
                if event.key == pygame.K_SPACE:
                    projectile = Projectile(player.x + player.width // 2, player.y)
                    projectiles.append(projectile)

        keys = pygame.key.get_pressed()
        player.move(keys)

        for projectile in projectiles:
            projectile.move()
            if projectile.off_screen():
                projectiles.remove(projectile)
        
        for enemy in enemies:
            enemy.move()
            for projectile in projectiles:
                if enemy.collide(projectile):
                    enemies.remove(enemy)
                    projectiles.remove(projectile)
                    score += 1
                    break

        WIN.fill(WHITE)
        player.draw(WIN)
        for enemy in enemies:
            enemy.draw(WIN)
        for projectile in projectiles:
            projectile.draw(WIN)
        
        score_text = font.render(f"Score: {score}", True, (0, 0, 0))
        WIN.blit(score_text, (10, 10))

        pygame.display.update()

    pygame.quit()
    sys.exit()

if __name__ == "__main__":
    main()
import pygame

# Classe Player
class Player:
    def __init__(self, x, y):
        self.x = x
        self.y = y
        self.width = 50
        self.height = 50
        self.color = (0, 0, 255)
        self.vel = 5

    def draw(self, win):
        pygame.draw.rect(win, self.color, (self.x, self.y, self.width, self.height))

    def move(self, keys):
        if keys[pygame.K_LEFT] and self.x - self.vel > 0:  # LEFT
            self.x -= self.vel
        if keys[pygame.K_RIGHT] and self.x + self.vel + self.width < 800:  # RIGHT
            self.x += self.vel
        if keys[pygame.K_UP] and self.y - self.vel > 0:  # UP
            self.y -= self.vel
        if keys[pygame.K_DOWN] and self.y + self.vel + self.height < 600:  # DOWN
            self.y += self.vel
import pygame
import random

# Classe Enemy
class Enemy:
    def __init__(self, x, y):
        self.x = x
        self.y = y
        self.width = 50
        self.height = 50
        self.color = (255, 0, 0)
        self.vel = 2

    def draw(self, win):
        pygame.draw.rect(win, self.color, (self.x, self.y, self.width, self.height))

    def move(self):
        directions = [(1, 0), (-1, 0), (0, 1), (0, -1)]
        dir_x, dir_y = random.choice(directions)
        self.x += dir_x * self.vel
        self.y += dir_y * self.vel

        # Garder l'ennemi dans les limites de la fenêtre
        if self.x < 0:
            self.x = 0
        elif self.x + self.width > 800:
            self.x = 800 - self.width
        if self.y < 0:
            self.y = 0
        elif self.y + self.height > 600:
            self.y = 600 - self.height

    def collide(self, projectile):
        return (self.x < projectile.x < self.x + self.width and
                self.y < projectile.y < self.y + self.height)
import pygame

# Classe Projectile
class Projectile:
    def __init__(self, x, y):
        self.x = x
        self.y = y
        self.radius = 5
        self.color = (0, 0, 0)
        self.vel = 10

    def draw(self, win):
        pygame.draw.circle(win, self.color, (self.x, self.y), self.radius)

    def move(self):
        self.y -= self.vel

    def off_screen(self):
        return self.y < 0
import pygame

# Classe Character de base
class Character:
    def __init__(self, x, y, width, height, color, vel):
        self.x = x
        self.y = y
        self.width = width
        self.height = height
        self.color = color
        self.vel = vel

    def draw(self, win):
        pygame.draw.rect(win, self.color, (self.x, self.y, self.width, self.height))

    def move(self, keys, left, right, up, down):
        if keys[left] and self.x - self.vel > 0:  # LEFT
            self.x -= self.vel
        if keys[right] and self.x + self.vel + self.width < 800:  # RIGHT
            self.x += self.vel
        if keys[up] and self.y - self.vel > 0:  # UP
            self.y -= self.vel
        if keys[down] and self.y + self.vel + self.height < 600:  # DOWN
            self.y += self.vel

# Classe Player héritée de Character
class Player(Character):
    def __init__(self, x, y):
        super().__init__(x, y, 50, 50, (0, 0, 255), 5)

# Classe Enemy héritée de Character
class Enemy(Character):
    def __init__(self, x, y):
        super().__init__(x, y, 50, 50, (255, 0, 0), 2)

    def move(self):
        directions = [(1, 0), (-1, 0), (0, 1), (0, -1)]
        dir_x, dir_y = random.choice(directions)
        self.x += dir_x * self.vel
        self.y += dir_y * self.vel

        # Garder l'ennemi dans les limites de la fenêtre
        if self.x < 0:
            self.x = 0
        elif self.x + self.width > 800:
            self.x = 800 - self.width
        if self.y < 0:
            self.y = 0
        elif self.y + self.height > 600:
            self.y = 600 - self.height

    def collide(self, projectile):
        return (self.x < projectile.x < self.x + self.width and
                self.y < projectile.y < self.y + self.height)
import pygame

# Classe Projectile
class Projectile:
    def __init__(self, x, y):
        self.x = x
        self.y = y
        self.radius = 5
        self.color = (0, 0, 0)
        self.vel = 10

    def draw(self, win):
        pygame.draw.circle(win, self.color, (self.x, self.y), self.radius)

    def move(self):
        self.y -= self.vel

    def off_screen(self):
        return self.y < 0
import pygame
import sys
import random
from character import Player, Enemy
from projectile import Projectile

# Initialisation de Pygame
pygame.init()

# Paramètres de la fenêtre
WIDTH, HEIGHT = 800, 600
WIN = pygame.display.set_mode((WIDTH, HEIGHT))
pygame.display.set_caption("Mini Brawl Stars")

# Couleurs
WHITE = (255, 255, 255)

# FPS
FPS = 60

# Fonction principale du jeu
def main():
    clock = pygame.time.Clock()
    player = Player(WIDTH // 2, HEIGHT // 2)
    enemies = [Enemy(WIDTH // 4, HEIGHT // 4)]
    projectiles = []
    score = 0

    font = pygame.font.Font(None, 36)

    run = True
    while run:
        clock.tick(FPS)
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                run = False
            if event.type == pygame.KEYDOWN:
                if event.key == pygame.K_SPACE:
                    projectile = Projectile(player.x + player.width // 2, player.y)
                    projectiles.append(projectile)

        keys = pygame.key.get_pressed()
        player.move(keys, pygame.K_LEFT, pygame.K_RIGHT, pygame.K_UP, pygame.K_DOWN)

        for projectile in projectiles:
            projectile.move()
            if projectile.off_screen():
                projectiles.remove(projectile)

        for enemy in enemies:
            enemy.move()
            for projectile in projectiles:
                if enemy.collide(projectile):
                    enemies.remove(enemy)
                    projectiles.remove(projectile)
                    score += 1
                    break

        WIN.fill(WHITE)
        player.draw(WIN)
        for enemy in enemies:
            enemy.draw(WIN)
        for projectile in projectiles:
            projectile.draw(WIN)

        score_text = font.render(f"Score: {score}", True, (0, 0, 0))
        WIN.blit(score_text, (10, 10))

        pygame.display.update()

    pygame.quit()
    sys.exit()

if __name__ == "__main__":
    main()
import pygame
import sys
import random
from character import Player, Enemy
from projectile import Projectile

# Initialisation de Pygame
pygame.init()

# Initialisation de Pygame mixer
pygame.mixer.init()

# Charger et jouer la musique
pygame.mixer.music.load('brawl_star_music.mp3')
pygame.mixer.music.play(-1)  # -1 pour jouer en boucle

# Paramètres de la fenêtre
WIDTH, HEIGHT = 800, 600
WIN = pygame.display.set_mode((WIDTH, HEIGHT))
pygame.display.set_caption("Mini Brawl Stars")

# Couleurs
WHITE = (255, 255, 255)

# FPS
FPS = 60

# Fonction principale du jeu
def main():
    clock = pygame.time.Clock()
    player = Player(WIDTH // 2, HEIGHT // 2)
    enemies = [Enemy(WIDTH // 4, HEIGHT // 4)]
    projectiles = []
    score = 0

    font = pygame.font.Font(None, 36)

    run = True
    while run:
        clock.tick(FPS)
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                run = False
            if event.type == pygame.KEYDOWN:
                if event.key == pygame.K_SPACE:
                    projectile = Projectile(player.x + player.width // 2, player.y)
                    projectiles.append(projectile)

        keys = pygame.key.get_pressed()
        player.move(keys, pygame.K_LEFT, pygame.K_RIGHT, pygame.K_UP, pygame.K_DOWN)

        for projectile in projectiles:
            projectile.move()
            if projectile.off_screen():
                projectiles.remove(projectile)

        for enemy in enemies:
            enemy.move()
            for projectile in projectiles:
                if enemy.collide(projectile):
                    enemies.remove(enemy)
                    projectiles.remove(projectile)
                    score += 1
                    break

        WIN.fill(WHITE)
        player.draw(WIN)
        for enemy in enemies:
            enemy.draw(WIN)
        for projectile in projectiles:
            projectile.draw(WIN)

        score_text = font.render(f"Score: {score}", True, (0, 0, 0))
        WIN.blit(score_text, (10, 10))

        pygame.display.update()

    pygame.quit()
    sys.exit()

if __name__ == "__main__":
    main()
import pygame

class Character:
    def __init__(self, x, y, width, height, color, vel):
        self.x = x
        self.y = y
        self.width = width
        self.height = height
        self.color = color
        self.vel = vel
        self.animations = {}
        self.current_animation = None
        self.frame_index = 0
        self.animation_speed = 0.1

    def draw(self, win):
        if self.current_animation:
            frames = self.animations[self.current_animation]
            frame = frames[int(self.frame_index) % len(frames)]
            win.blit(frame, (self.x, self.y))
            self.frame_index += self.animation_speed
        else:
            pygame.draw.rect(win, self.color, (self.x, self.y, self.width, self.height))

    def move(self, keys, left, right, up, down):
        if keys[left] and self.x - self.vel > 0:
            self.x -= self.vel
        if keys[right] and self.x + self.vel + self.width < 800:
            self.x += self.vel
        if keys[up] and self.y - self.vel > 0:
            self.y -= self.vel
        if keys[down] and self.y + self.vel + self.height < 600:
            self.y += self.vel

class Player(Character):
    def __init__(self, x, y):
        super().__init__(x, y, 50, 50, (0, 0, 255), 5)
        self.load_animations()

    def load_animations(self):
        self.animations['idle'] = [pygame.image.load(f'player_idle_{i}.png') for i in range(4)]
        self.current_animation = 'idle'
class FastPlayer(Player):
    def __init__(self, x, y):
        super().__init__(x, y)
        self.vel = 8

class StrongPlayer(Player):
    def __init__(self, x, y):
        super().__init__(x, y)
        self.width = 60
        self.height = 60
        self.color = (0, 255, 0)
import pygame

class PowerUp:
    def __init__(self, x, y):
        self.x = x
        self.y = y
        self.width = 20
        self.height = 20
        self.color = (255, 255, 0)
        self.type = random.choice(['speed', 'health'])

    def draw(self, win):
        pygame.draw.rect(win, self.color, (self.x, self.y, self.width, self.height))

    def apply(self, player):
        if self.type == 'speed':
            player.vel += 2
        elif self.type == 'health':
            player.health += 20
import pygame
import sys
import random
from character import Player, Enemy, FastPlayer, StrongPlayer
from projectile import Projectile
from powerup import PowerUp

# Initialisation de Pygame
pygame.init()
pygame.mixer.init()
pygame.mixer.music.load('brawl_star_music.mp3')
pygame.mixer.music.play(-1)

WIDTH, HEIGHT = 800, 600
WIN = pygame.display.set_mode((WIDTH, HEIGHT))
pygame.display.set_caption("Mini Brawl Stars")

WHITE = (255, 255, 255)
FPS = 60

def main():
    clock = pygame.time.Clock()
    player = Player(WIDTH // 2, HEIGHT // 2)
    enemies = [Enemy(WIDTH // 4, HEIGHT // 4)]
    projectiles = []
    powerups = [PowerUp(random.randint(0, WIDTH), random.randint(0, HEIGHT))]
    score = 0
    font = pygame.font.Font(None, 36)
    
    run = True
    while run:
        clock.tick(FPS)
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                run = False
            if event.type == pygame.KEYDOWN:
                if event.key == pygame.K_SPACE:
                    projectile = Projectile(player.x + player.width // 2, player.y)
                    projectiles.append(projectile)

        keys = pygame.key.get_pressed()
        player.move(keys, pygame.K_LEFT, pygame.K_RIGHT, pygame.K_UP, pygame.K_DOWN)

        for projectile in projectiles:
            projectile.move()
            if projectile.off_screen():
                projectiles.remove(projectile)

        for enemy in enemies:
            enemy.move()
            for projectile in projectiles:
                if enemy.collide(projectile):
                    enemies.remove(enemy)
                    projectiles.remove(projectile)
                    score += 1
                    break

        for powerup in powerups:
            if player.x < powerup.x < player.x + player.width and player.y < powerup.y < player.y + player.height:
                powerup.apply(player)
                powerups.remove(powerup)

        WIN.fill(WHITE)
        player.draw(WIN)
        for enemy in enemies:
            enemy.draw(WIN)
        for projectile in projectiles:
            projectile.draw(WIN)
        for powerup in powerups:
            powerup.draw(WIN)

        score_text = font.render(f"Score: {score}", True, (0, 0, 0))
        WIN.blit(score_text, (10, 10))

        pygame.display.update()

    pygame.quit()
    sys.exit()

if __name__ == "__main__":
    main()
class Character:
    def __init__(self, x, y, width, height, color, vel):
        self.x = x
        self.y = y
        self.width = width
        self.height = height
        self.color = color
        self.vel = vel
        self.health = 100

    def draw(self, win):
        pygame.draw.rect(win, self.color, (self.x, self.y, self.width, self.height))
        self.draw_health_bar(win)

    def draw_health_bar(self, win):
        if self.health > 0:
            pygame.draw.rect(win, (255, 0, 0), (self.x, self.y - 10, self.width, 5))
            pygame.draw.rect(win, (0, 255, 0), (self.x, self.y 

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: