Feat[projectiles], add assets for the projectile of the player

This commit is contained in:
MateoLT
2025-04-04 11:51:43 +02:00
parent de7158b6fb
commit e5ed01f3c3
4 changed files with 12 additions and 2 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 38 KiB

View File

@@ -502,6 +502,7 @@ class Player(Entity):
damage=1,
color=(165, 42, 42),
enemy_proj=False,
texturePath="assets/player/Boule de feu.png",
)
# Add projectile to the sprite group (to be placed in main.py)
pygame.event.post(
@@ -525,6 +526,7 @@ class Player(Entity):
damage=1,
color=(165, 42, 42),
enemy_proj=False,
texturePath="assets/player/Boule de feu.png",
)
# Add projectile to the sprite group (to be placed in main.py)
pygame.event.post(

View File

@@ -5,10 +5,17 @@ from pygame.math import Vector2 as vec
class Projectile(Entity):
def __init__(
self, pos, direction, speed, damage, color=(0, 0, 255), enemy_proj=False
self,
pos,
direction,
speed,
damage,
color=(0, 0, 255),
enemy_proj=False,
texturePath="",
):
# Appel du constructeur parent avec les paramètres appropriés
super().__init__(pos=pos, size=(10, 10), color=color)
super().__init__(pos=pos, size=(50, 50), color=color, texturePath=texturePath)
# Attributs spécifiques aux projectiles
self.direction = direction.normalize() if direction.length() > 0 else vec(1, 0)

View File

@@ -245,6 +245,7 @@ def handler():
P1.move()
P1.update()
P1.attack()
projectiles.update(WIDTH, HEIGHT, P1, camera)
# Update camera to follow player
camera.update(P1)