summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--components/button.gd2
-rw-r--r--components/healthbar/healtbar.gd2
-rw-r--r--scenes/levels/base_level.gd5
-rw-r--r--scenes/levels/base_level.tscn3
-rw-r--r--scenes/levels/level1.gd16
5 files changed, 17 insertions, 11 deletions
diff --git a/components/button.gd b/components/button.gd
index 6ed79be..45a3f4f 100644
--- a/components/button.gd
+++ b/components/button.gd
@@ -39,6 +39,8 @@ func _ready():
func _text(value):
text = value
+ if label == null:
+ return
_text_changed()
func _text_changed():
diff --git a/components/healthbar/healtbar.gd b/components/healthbar/healtbar.gd
index a78a81d..b2df800 100644
--- a/components/healthbar/healtbar.gd
+++ b/components/healthbar/healtbar.gd
@@ -1,6 +1,6 @@
extends Node2D
-export var maxhealth = 3
+export var maxhealth = 10
export var offset = 40
var h: PackedScene = preload("res://components/healthbar/heart.tscn")
diff --git a/scenes/levels/base_level.gd b/scenes/levels/base_level.gd
index d3a17a6..f7d9cbe 100644
--- a/scenes/levels/base_level.gd
+++ b/scenes/levels/base_level.gd
@@ -7,7 +7,7 @@ onready var _path_renderer : PathRenderer = $PathRenderer
onready var _health_bar = $Camera2D/healthbar
onready var _last_camera_location : Vector2 = $Camera2D.position
const _levels = [
- preload("res://scenes/levels/repeat_this.tscn")
+ preload("res://scenes/levels/level1.tscn")
]
var _current_level = 0
@@ -17,7 +17,7 @@ var _health = 10
# Called when the node enters the scene tree for the first time.
func _ready():
- _health_bar.maxhealth = 10
+ _health_bar.set_health(10)
_load_current_level()
func _get_next_level_pos() -> Vector2:
@@ -52,6 +52,7 @@ func _load_next_level():
_current_level += 1
if _current_level > _levels.size():
get_tree().change_scene("res://scenes/menu.tscn")
+ return
_load_current_level()
func _unload_current_level():
diff --git a/scenes/levels/base_level.tscn b/scenes/levels/base_level.tscn
index 055e0f4..66eabfc 100644
--- a/scenes/levels/base_level.tscn
+++ b/scenes/levels/base_level.tscn
@@ -24,7 +24,7 @@ script = ExtResource( 7 )
[node name="healthbar" parent="Camera2D" instance=ExtResource( 3 )]
position = Vector2( -595.377, -321.363 )
-maxhealth = 3
+maxhealth = 10
offset = 60
[node name="background_blue" type="Sprite" parent="Camera2D"]
@@ -39,5 +39,6 @@ text = "Menu"
[node name="PauseMenu" parent="Camera2D" instance=ExtResource( 5 )]
visible = false
+
[connection signal="done" from="Camera2D" to="." method="_on_Camera2D_done"]
[connection signal="on_click" from="Camera2D/MenuButton" to="." method="_on_MenuButton_on_click"]
diff --git a/scenes/levels/level1.gd b/scenes/levels/level1.gd
index 89dba81..9d48dfd 100644
--- a/scenes/levels/level1.gd
+++ b/scenes/levels/level1.gd
@@ -2,20 +2,22 @@ extends Level
onready var buttons = $ButtonHolder.get_children()
-var order = [
- 9, 8, 7, 6, 5, 4, 3, 2, 1, 0
-]
var sequence_index = 0
func _ready():
for i in range(buttons.size()):
- buttons[i].connect("on_click", self, "_on_AnyButton_click", [i])
- buttons[i].text = str(i)
- # buttons[i].visible = false
+ buttons[i].connect("on_click", self, "_on_Any_button_click", [i])
+ buttons[i].text = str(i + 1)
+ if i != 0:
+ buttons[i].visible = false
func _on_Any_button_click(btn_idx):
- if btn_idx == order[sequence_index]:
+ if btn_idx == sequence_index:
sequence_index += 1
+ if sequence_index == buttons.size():
+ finish_level()
+ buttons[sequence_index].visible = true
print("Correct button: ", btn_idx)
else:
+ lose_heart()
print("Incorrect button: ", btn_idx)