summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorJan Tuomi <jan.tuomi@valuemotive.com>2020-08-01 15:51:18 +0300
committerJan Tuomi <jan.tuomi@valuemotive.com>2020-08-01 15:51:18 +0300
commitbc73f5f075540c2f60b3ec2e216a3ecda85fdfc3 (patch)
tree3f8bb7878c8aa36ecb30f0fe85c5114ab256c8f5 /scripts
parent5e45d3f7b24b022040f47a8ab2d6bf4bb4d9b8b6 (diff)
Add GUI
Diffstat (limited to 'scripts')
-rw-r--r--scripts/GUI.gd18
-rw-r--r--scripts/PlayerCharacter.gd3
2 files changed, 21 insertions, 0 deletions
diff --git a/scripts/GUI.gd b/scripts/GUI.gd
new file mode 100644
index 0000000..1e0a781
--- /dev/null
+++ b/scripts/GUI.gd
@@ -0,0 +1,18 @@
+extends MarginContainer
+class_name GUI
+
+# Declare member variables here. Examples:
+# var a = 2
+# var b = "text"
+
+
+# Called when the node enters the scene tree for the first time.
+func _ready():
+ pass # Replace with function body.
+
+# Called every frame. 'delta' is the elapsed time since the previous frame.
+func _process(_delta):
+ pass
+
+func set_debug_text(text: String):
+ $VBoxContainer/Label.set_text(text)
diff --git a/scripts/PlayerCharacter.gd b/scripts/PlayerCharacter.gd
index 9c95854..1df100c 100644
--- a/scripts/PlayerCharacter.gd
+++ b/scripts/PlayerCharacter.gd
@@ -3,6 +3,7 @@ class_name PlayerCharacter
export (int) var speed = 8
export (float) var walk_wobble_coeff = 5
+export (NodePath) var gui_node
var velocity = Vector2()
var look_dir = 1 # right = 1, left = -1
@@ -67,8 +68,10 @@ func _physics_process(_delta):
func change_level(num: int):
var new_scene = "res://scenes/Scene" + String(num) + ".tscn"
+ var gui: GUI = get_node(gui_node)
var success = get_tree().change_scene(new_scene)
if success == OK:
+ gui.set_debug_text("Level: %s" % num)
print("Changed level to " + new_scene)
else:
push_error("Failed to change level to " + new_scene)