diff options
| author | altaf-creator <dev@altafcreator.com> | 2025-10-20 01:43:48 +0800 |
|---|---|---|
| committer | altaf-creator <dev@altafcreator.com> | 2025-10-20 01:43:48 +0800 |
| commit | 466bec0b724632f6dd2e1555a7bd58ffc1dd0458 (patch) | |
| tree | d6645ea11914edeec645299fa497a9e542dbaec7 /Scripts/Weapons/Bow.gd | |
Jam version.
Diffstat (limited to 'Scripts/Weapons/Bow.gd')
| -rw-r--r-- | Scripts/Weapons/Bow.gd | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/Scripts/Weapons/Bow.gd b/Scripts/Weapons/Bow.gd new file mode 100644 index 0000000..09ffa3c --- /dev/null +++ b/Scripts/Weapons/Bow.gd @@ -0,0 +1,22 @@ +extends Node2D + +@export var arrow : PackedScene +@export var speed : float + +# 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: + pass + +func action() -> void: + var pivot = get_node("../../") + var new = arrow.instantiate() + new.init_vel = Vector2.DOWN.rotated(pivot.rotation) * speed + new.global_position = global_position + var normalised = new.init_vel.normalized() + new.sprite.rotation = atan2(normalised.y, normalised.x) + get_tree().get_root().get_node("Node2D").add_child(new) |
