1
Fork 0
mirror of https://github.com/RYGhub/the-cold-night.git synced 2024-11-25 14:14:19 +00:00

⚙️ Shooting time limitations

This commit is contained in:
Cookie-CHR 2022-04-03 16:44:18 +02:00
parent 6fa26636ba
commit fc8d4bc8ac

View file

@ -5,12 +5,25 @@ export var bullet: PackedScene = preload("res://src/entities/Bullet.tscn")
export var bullet_container_node_path: String = "../.." export var bullet_container_node_path: String = "../.."
onready var bullet_container_node: Node = get_node(bullet_container_node_path) onready var bullet_container_node: Node = get_node(bullet_container_node_path)
onready var source: Node2D = get_parent() onready var source: Node2D = get_parent()
var _timer : Timer = null
func _ready():
_timer = Timer.new()
add_child(_timer)
_timer.set_wait_time(0.3)
_timer.set_one_shot(true)
_timer.start()
func _process(_delta): func _process(_delta):
if Input.is_action_just_pressed("player_shoot"): print(_timer.get_time_left())
if Input.is_action_just_pressed("player_shoot") and _timer.get_time_left()==0:
shoot() shoot()
#restart timer
_timer.set_wait_time(0.3)
_timer.set_one_shot(true)
_timer.start()
func shoot(): func shoot():
var new_bullet = bullet.instance() var new_bullet = bullet.instance()