2024-09-10 01:02:01 +00:00
|
|
|
extends Area2D
|
2024-09-17 01:06:36 +00:00
|
|
|
@onready var bulletsprite: Sprite2D = $Sprite2D
|
2024-09-10 01:02:01 +00:00
|
|
|
|
|
|
|
var speed := 700
|
|
|
|
signal hit(bullet, body)
|
|
|
|
|
|
|
|
func setSpeed(speedVal):
|
|
|
|
speed = speedVal
|
2024-09-17 01:06:36 +00:00
|
|
|
if speedVal < 0:
|
|
|
|
bulletsprite.flip_h = true
|
|
|
|
else:
|
|
|
|
bulletsprite.flip_h = false
|
2024-09-10 01:02:01 +00:00
|
|
|
|
|
|
|
func _physics_process(delta: float) -> void:
|
|
|
|
position += transform.x * speed * delta
|
|
|
|
|
|
|
|
func _on_body_entered(body: Node2D) -> void:
|
2024-10-08 00:56:53 +00:00
|
|
|
if body is Enemy:
|
|
|
|
print("blow away enemy")
|
|
|
|
|
|
|
|
func _on_area_entered(area: Area2D) -> void:
|
|
|
|
if area is Enemy:
|
|
|
|
print("blow this enemy away")
|
|
|
|
hit.emit(self, area)
|