diff options
author | rom <romangraef@gmail.com> | 2021-04-25 23:55:11 +0200 |
---|---|---|
committer | rom <romangraef@gmail.com> | 2021-04-25 23:55:18 +0200 |
commit | 02019c028d46fd3ce98d022f72862f735ca9229c (patch) | |
tree | 22b7a97e979aad715f3a9921680d63e41c1be1a0 /scenes/levels | |
parent | b43f35d2183ab5fd236ad9c04b7da0cadf55ba00 (diff) | |
download | ldjam48-02019c028d46fd3ce98d022f72862f735ca9229c.tar.gz ldjam48-02019c028d46fd3ce98d022f72862f735ca9229c.tar.bz2 ldjam48-02019c028d46fd3ce98d022f72862f735ca9229c.zip |
hearts and base lebel
Diffstat (limited to 'scenes/levels')
-rw-r--r-- | scenes/levels/base_level.gd | 5 | ||||
-rw-r--r-- | scenes/levels/base_level.tscn | 3 | ||||
-rw-r--r-- | scenes/levels/level1.gd | 16 |
3 files changed, 14 insertions, 10 deletions
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) |