homework
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
extends Area2D
|
||||
|
||||
@export var SPEED : float = 450.0
|
||||
@export var timing : float = 4.0
|
||||
var target_pos : Vector2
|
||||
var direction : Vector2 = Vector2.RIGHT
|
||||
|
||||
func _ready() -> void:
|
||||
add_to_group("bullet")
|
||||
direction = (target_pos - global_position).normalized()
|
||||
await get_tree().create_timer(timing).timeout
|
||||
queue_free()
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
global_position += direction * SPEED * delta
|
||||
|
||||
|
||||
|
||||
func _on_body_entered(body: Node2D) -> void:
|
||||
if body.is_in_group("enemy") or body.is_in_group("wall") or body.is_in_group("blcok"):
|
||||
if body.has_method("take_damage"):
|
||||
body.take_damage(10,0.55,0.4)
|
||||
queue_free()
|
||||
elif body.is_in_group("wall"):
|
||||
queue_free()
|
||||
Reference in New Issue
Block a user