Code cleanup, added more functionality. Floating coffins that spawn items, graves can spawn zombies, etc.

This commit is contained in:
Storm Dragon
2025-01-30 22:22:59 -05:00
parent 53009373c2
commit 6c000d78d8
10 changed files with 402 additions and 15 deletions

29
src/projectile.py Normal file
View File

@@ -0,0 +1,29 @@
class Projectile:
def __init__(self, projectile_type, start_x, direction):
self.type = projectile_type
self.x = start_x
self.direction = direction
self.speed = 0.2 # Projectiles move faster than player
self.isActive = True
self.damage = 5 # All projectiles do same damage for now
self.range = 10 # Maximum travel distance in tiles
self.start_x = start_x
def update(self):
"""Update projectile position and check if it should still exist"""
if not self.isActive:
return False
self.x += self.direction * self.speed
# Check if projectile has gone too far
if abs(self.x - self.start_x) > self.range:
self.isActive = False
return False
return True
def hit_enemy(self, enemy):
"""Handle hitting an enemy"""
enemy.take_damage(self.damage)
self.isActive = False # Projectile is destroyed on hit