#11 installation d'une ui simpliste
This commit is contained in:
@@ -1,12 +1,22 @@
|
||||
extends CharacterBody2D
|
||||
class_name Player
|
||||
|
||||
signal player_stats_updated(player : Player)
|
||||
|
||||
@export var speed = 400
|
||||
|
||||
var energy : int = 10 :
|
||||
set(v):
|
||||
energy = v
|
||||
emit_signal("player_stats_updated", self)
|
||||
|
||||
func _ready():
|
||||
emit_signal("player_stats_updated", self)
|
||||
|
||||
func get_input():
|
||||
calculate_direction()
|
||||
|
||||
if Input.is_action_just_pressed("interact"):
|
||||
if Input.is_action_just_pressed("interact") and energy > 0:
|
||||
try_interact()
|
||||
|
||||
func calculate_direction():
|
||||
@@ -31,6 +41,7 @@ func try_interact():
|
||||
)
|
||||
|
||||
interactables[0].interact(self)
|
||||
energy -= 1
|
||||
|
||||
func _physics_process(_delta):
|
||||
get_input()
|
||||
|
||||
Reference in New Issue
Block a user