Files
LuminaDeflect/player/player.gd
2024-05-28 11:03:29 -05:00

23 lines
734 B
GDScript

extends CharacterBody2D
@export var speed = 1750
var can_primary = true
const BULLET = preload("res://bullet.tscn")
func _physics_process(delta: float) -> void:
var direction = Input.get_vector("ui_left", "ui_right", "ui_up", "ui_down")
velocity = direction * speed * delta
move_and_slide()
var look_direction = Input.get_vector("look_left","look_right","look_up","look_down")
if look_direction:
rotation = look_direction.angle()
if Input.is_action_pressed("primary_fire") and can_primary:
print("primary fire")
var fire = BULLET.instantiate()
fire.direction = rotation
fire.position = position
add_sibling(fire)
can_primary = false
get_tree().create_timer(1.1).timeout.connect(func (): can_primary = true)