diff options
Diffstat (limited to 'scenes/levels')
-rw-r--r-- | scenes/levels/base_level.gd | 18 | ||||
-rw-r--r-- | scenes/levels/base_level.tscn | 8 | ||||
-rw-r--r-- | scenes/levels/reactiontest.gd | 21 | ||||
-rw-r--r-- | scenes/levels/reactiontest.tscn | 13 |
4 files changed, 56 insertions, 4 deletions
diff --git a/scenes/levels/base_level.gd b/scenes/levels/base_level.gd index c7e68ee..df08a32 100644 --- a/scenes/levels/base_level.gd +++ b/scenes/levels/base_level.gd @@ -77,9 +77,27 @@ func _load_current_level(): _camera.path = _track func _on_MenuButton_on_click(): + _disable_input(_level_holder) _pause_menu.pause() func _on_Camera2D_done(): print("Camera movement done") _loaded_level.start() + +func _disable_input(node): + # this is barbaric + if node is Control: + node.mouse_filter = Control.MOUSE_FILTER_IGNORE + for n in node.get_children(): + _disable_input(n) + +func _enable_input(node): + if node is Control: + node.mouse_filter = Control.MOUSE_FILTER_STOP + for n in node.get_children(): + _enable_input(n) + +func _on_PauseMenu_unpause(): + _enable_input(_level_holder) + _level_holder.set_process_input(true) diff --git a/scenes/levels/base_level.tscn b/scenes/levels/base_level.tscn index 5f0a4a6..e2d57ba 100644 --- a/scenes/levels/base_level.tscn +++ b/scenes/levels/base_level.tscn @@ -15,7 +15,10 @@ script = ExtResource( 6 ) script = ExtResource( 2 ) path_color = Color( 0, 0.741176, 1, 1 ) -[node name="LevelHolder" type="Node2D" parent="."] +[node name="LevelHolder" type="Control" parent="."] +__meta__ = { +"_edit_use_anchors_": false +} [node name="Camera2D" type="Camera2D" parent="."] position = Vector2( 153.457, 427.259 ) @@ -38,6 +41,7 @@ position = Vector2( 571.642, -311.599 ) 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"] +[connection signal="unpause" from="Camera2D/PauseMenu" to="." method="_on_PauseMenu_unpause"] diff --git a/scenes/levels/reactiontest.gd b/scenes/levels/reactiontest.gd index 707b97a..50f5ce2 100644 --- a/scenes/levels/reactiontest.gd +++ b/scenes/levels/reactiontest.gd @@ -1,20 +1,39 @@ extends Level onready var buttons = $ButtonHolder.get_children() - +onready var timer_label = $TimerLabel var sequence_index = 0 +var timer = 0 +var running = false + +func _total_time(): + if Settings.difficulty == Settings.Difficulty.HARD: + return 10 + return 60 + +func start(): + .start() + running = true + func _ready(): + timer = 0 for i in range(buttons.size()): 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 _process(delta): + if running: + timer += delta + timer_label.text = str(_total_time() - timer) + func _on_Any_button_click(btn_idx): if btn_idx == sequence_index: sequence_index += 1 if sequence_index == buttons.size(): + running = false finish_level() return buttons[sequence_index].visible = true diff --git a/scenes/levels/reactiontest.tscn b/scenes/levels/reactiontest.tscn index 8c98f6c..41031e3 100644 --- a/scenes/levels/reactiontest.tscn +++ b/scenes/levels/reactiontest.tscn @@ -1,7 +1,8 @@ -[gd_scene load_steps=3 format=2] +[gd_scene load_steps=4 format=2] [ext_resource path="res://scenes/levels/reactiontest.gd" type="Script" id=1] [ext_resource path="res://components/button.tscn" type="PackedScene" id=2] +[ext_resource path="res://fonts/Flipps_Theme.tres" type="Theme" id=3] [node name="Level2" type="Node2D"] position = Vector2( 640, 320 ) @@ -53,3 +54,13 @@ fixed_width = 30 position = Vector2( 216.1, -39.8346 ) text = "9" fixed_width = 30 + +[node name="TimerLabel" type="Label" parent="."] +margin_left = -625.51 +margin_top = -296.265 +margin_right = -501.51 +margin_bottom = -215.265 +theme = ExtResource( 3 ) +__meta__ = { +"_edit_use_anchors_": false +} |