This repository has been archived on 2024-09-30. You can view files and clone it, but cannot push or open issues/pull-requests.
gbjam12/puzzles/arrow/arrow.gd

30 lines
535 B
GDScript

class_name Arrow
extends Node2D
@onready var sprite: Sprite2D = $Sprite2D
var _direction: Vector2i
var _speed: int = 50
func _ready():
if _direction.x > 0:
sprite.flip_h = true
if _direction.y < 0:
rotation_degrees = 90
if _direction.y > 0:
rotation_degrees = -90
func shoot(dir: Vector2i, speed: int):
_direction = dir
_speed = speed
func _physics_process(delta):
var move = _direction * _speed * delta
position = position + move
func _on_area_2d_body_entered(body):
if body is Player:
body.die()
queue_free()