added green attack, enemy

This commit is contained in:
Daniel Kauss Serna 2026-03-13 17:10:47 +01:00
parent f852b0a30e
commit 2bf9db610e
43 changed files with 673 additions and 246 deletions

View file

@ -1,30 +1,35 @@
class_name Hitbox extends Area2D
signal collided;
signal hit_entity(entity : Entity);
signal hit_obstacle;
var from_player = true
var enabled = true
@export var deal_damage = true
func _ready() -> void:
collision_mask = 0xffff
collision_mask = 1 | 2 | 4
body_entered.connect(_on_body_entered)
area_entered.connect(_on_area_entered)
func _on_area_entered(area : Area2D):
if area is Hitbox:
if area.from_player != from_player:
collided.emit()
hit_obstacle.emit()
func _on_body_entered(body: Node) -> void:
print(body)
if not enabled: return
if body is Enemy and from_player:
body.damage()
collided.emit()
body.knockback()
if deal_damage:
body.damage()
body.knockback()
hit_entity.emit(body)
if body is Player and not from_player:
body.damage()
collided.emit()
if deal_damage:
body.damage()
hit_entity.emit(body)
if body is StaticBody2D or body is Hitbox:
collided.emit()
if body is StaticBody2D:
hit_obstacle.emit()