game1/scripts/bullet.gd

25 lines
563 B
GDScript3
Raw Normal View History

2025-08-18 02:18:14 +00:00
class_name Bullet extends Area2D
2025-08-26 01:07:18 +00:00
@onready var bullet_graphic: Sprite2D = $bullet_graphic
2025-08-18 02:18:14 +00:00
var speed: float = 700
signal bulletDamageSignal(target: Node2D, bullet: Node2D)
2025-08-26 01:07:18 +00:00
func setSpeed(value: float):
speed = value
if value<0:
bullet_graphic.flip_h = true
if value>0:
bullet_graphic.flip_h= false
2025-08-18 02:18:14 +00:00
func _physics_process(delta: float) -> void:
position+=transform.x*speed*delta
func _on_body_entered(body: Node2D) -> void:
if body is Player:
return
print("emit?")
if body is Crate && visible:
print("emit")
bulletDamageSignal.emit(body, self)