init
This commit is contained in:
22
player/player.gd
Normal file
22
player/player.gd
Normal file
@@ -0,0 +1,22 @@
|
||||
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)
|
||||
Reference in New Issue
Block a user