feat: arrows and stuff
This commit is contained in:
36
arrow/arrow.gd
Normal file
36
arrow/arrow.gd
Normal file
@ -0,0 +1,36 @@
|
||||
extends RigidBody2D
|
||||
|
||||
@onready var area_2d: Area2D = $Area2D
|
||||
@onready var kill_after: Timer = $KillAfter
|
||||
|
||||
@export var speed = 100
|
||||
@export var rotation_speed = 1
|
||||
@export var jump_strength_on_death = 100
|
||||
var is_moving = true
|
||||
var first_frame_available = true
|
||||
|
||||
func _ready() -> void:
|
||||
freeze = true
|
||||
|
||||
func _physics_process(delta: float) -> void:
|
||||
if is_moving:
|
||||
position.x -= speed
|
||||
else:
|
||||
freeze = false
|
||||
area_2d.monitoring = false
|
||||
area_2d.monitorable = false
|
||||
|
||||
linear_velocity.x = 0
|
||||
linear_velocity += get_gravity() * delta
|
||||
angular_velocity = rotation_speed
|
||||
|
||||
if first_frame_available:
|
||||
apply_impulse(Vector2.UP * jump_strength_on_death)
|
||||
first_frame_available = false
|
||||
|
||||
func _on_kill_after_timeout() -> void:
|
||||
queue_free()
|
||||
|
||||
func _on_body_entered(body: Node) -> void:
|
||||
is_moving = false
|
||||
kill_after.start()
|
Reference in New Issue
Block a user