cute lil prototype
This commit is contained in:
parent
57f147236a
commit
0e4a55d7bd
19 changed files with 305 additions and 2 deletions
32
battery_manager.gd
Normal file
32
battery_manager.gd
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
extends HBoxContainer
|
||||
|
||||
@export var current_battery : TextureProgressBar
|
||||
@export var battery_drain : float = 1
|
||||
@export var starting_batteries : int = 3
|
||||
var cb_value : float = 16
|
||||
var extra_batteries : int
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready() -> void:
|
||||
extra_batteries = starting_batteries -1
|
||||
redraw_extra_batteries()
|
||||
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _process(delta: float) -> void:
|
||||
if cb_value <= 0:
|
||||
extra_batteries -= 1
|
||||
cb_value = 16
|
||||
redraw_extra_batteries()
|
||||
var thrust : float = Input.get_action_strength("thrust")
|
||||
cb_value -= thrust * delta * battery_drain
|
||||
current_battery.value = cb_value
|
||||
|
||||
func redraw_extra_batteries():
|
||||
for i in range(get_children().size()):
|
||||
if(i != 0):
|
||||
get_child(i).queue_free()
|
||||
|
||||
for i in range(extra_batteries):
|
||||
var new_extra = load("res://Prefabs/spare_battery.tscn").instantiate()
|
||||
add_child(new_extra)
|
||||
Loading…
Add table
Add a link
Reference in a new issue