This repository has been archived on 2024-09-30. You can view files and clone it, but cannot push or open issues/pull-requests.
2024-09-17 21:37:22 +03:00
|
|
|
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
|
2024-09-20 22:50:26 +03:00
|
|
|
if _direction.y < 0:
|
|
|
|
rotation_degrees = 90
|
|
|
|
if _direction.y > 0:
|
|
|
|
rotation_degrees = -90
|
2024-09-17 21:37:22 +03:00
|
|
|
|
|
|
|
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()
|