ft (very very wip): prey impl

This commit is contained in:
djaidjai committed 2025-12-19 20:07:53 +01:00
1 parent 551482e209
commit a5055a523f
19 files changed
+226 -55

No files matched your search

@@ -0,0 +1,37 @@
extends AbstractPrey
@onready var sprite = get_node("AnimatedSprite2D")
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta: float) -> void:
self.move(Vector3(randfn(0, 1), randfn(0, 1), 0))
return
func move(destination: Vector3) -> void:
self.position += Vector2(destination.x, destination.y) # stub
func _on_rigid_body_2d_body_entered(body: Node) -> void:
# TODO: collision with other entities
# check if colision with player
print("we collidin")
if body.is_in_group("player"):
handle_collision_player(body)
else:
self.die()
# Function to handle collision logic
func handle_collision_player(player):
print("Collision!")
self.health -= player.str
if sprite:
if self.health <= 0:
self.die()
else:
sprite.play("injured")
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.