diff options
author | rom <romangraef@gmail.com> | 2021-04-26 23:56:42 +0200 |
---|---|---|
committer | rom <romangraef@gmail.com> | 2021-04-26 23:56:56 +0200 |
commit | a7b42bd030efaaa70769cda2e368a42b7ead4942 (patch) | |
tree | d7fe8e31c3827bcbb89a85289ee3983d60d76f95 | |
parent | 6b07fc93cea108bcbcce1cbab7c70721f2dcb85a (diff) | |
download | ldjam48-a7b42bd030efaaa70769cda2e368a42b7ead4942.tar.gz ldjam48-a7b42bd030efaaa70769cda2e368a42b7ead4942.tar.bz2 ldjam48-a7b42bd030efaaa70769cda2e368a42b7ead4942.zip |
pause & puzzle solver
-rw-r--r-- | components/Level.gd | 2 | ||||
-rw-r--r-- | scenes/background_music.gd | 3 | ||||
-rw-r--r-- | scenes/background_music.tscn | 7 | ||||
-rw-r--r-- | scenes/levels/pixel/PixelDefender.gd | 2 | ||||
-rw-r--r-- | scenes/levels/pixel/PixelDefender.tscn | 1 | ||||
-rw-r--r-- | scenes/levels/puzzle/puzzle.gd | 7 | ||||
-rw-r--r-- | scenes/levels/typeracer.gd | 2 | ||||
-rw-r--r-- | scenes/levels/typeracer.tscn | 1 | ||||
-rw-r--r-- | scenes/pause.gd | 6 |
9 files changed, 30 insertions, 1 deletions
diff --git a/components/Level.gd b/components/Level.gd index ad48336..49886cd 100644 --- a/components/Level.gd +++ b/components/Level.gd @@ -11,9 +11,11 @@ func start(): running = true func lose_heart(): + BackgroundMusic.lose_heart_sound() emit_signal("lost_heart", false) func lose_all_hearts(): + BackgroundMusic.lose_heart_sound() emit_signal("lost_heart", true) func finish_level(): diff --git a/scenes/background_music.gd b/scenes/background_music.gd index e2622ae..aaf5b5c 100644 --- a/scenes/background_music.gd +++ b/scenes/background_music.gd @@ -14,3 +14,6 @@ func click_sound(): func type_sound(): $Type.play() + +func lose_heart_sound(): + $LoseHeart.play() diff --git a/scenes/background_music.tscn b/scenes/background_music.tscn index bad9601..221be14 100644 --- a/scenes/background_music.tscn +++ b/scenes/background_music.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=7 format=2] +[gd_scene load_steps=8 format=2] [ext_resource path="res://sfx/sound_track_1.wav" type="AudioStream" id=1] [ext_resource path="res://scenes/background_music.gd" type="Script" id=2] @@ -6,11 +6,13 @@ [ext_resource path="res://sfx/hover.wav" type="AudioStream" id=4] [ext_resource path="res://sfx/click.wav" type="AudioStream" id=5] [ext_resource path="res://sfx/click2.wav" type="AudioStream" id=6] +[ext_resource path="res://sfx/loose_heart.wav" type="AudioStream" id=7] [node name="Parent" type="Node"] script = ExtResource( 2 ) [node name="Sound1" type="AudioStreamPlayer" parent="."] +pause_mode = 2 stream = ExtResource( 1 ) volume_db = -13.867 autoplay = true @@ -30,4 +32,7 @@ volume_db = -27.647 stream = ExtResource( 6 ) volume_db = -38.389 +[node name="LoseHeart" type="AudioStreamPlayer" parent="."] +stream = ExtResource( 7 ) + [connection signal="finished" from="Sound1" to="." method="_on_AudioStreamPlayer_finished"] diff --git a/scenes/levels/pixel/PixelDefender.gd b/scenes/levels/pixel/PixelDefender.gd index 5f8d516..ec2b26d 100644 --- a/scenes/levels/pixel/PixelDefender.gd +++ b/scenes/levels/pixel/PixelDefender.gd @@ -62,8 +62,10 @@ func _process(delta): func _on_enemy_area_shape_entered(area_id, area, area_shape, local_shape, e): if area is Bullet and area.team == Bullet.CHAOS: return + print(typeof(area), area) if area is Bullet: area.queue_free() + e.queue_free() elif area is Spaceship and area.team == Bullet.ORDER: e.queue_free() diff --git a/scenes/levels/pixel/PixelDefender.tscn b/scenes/levels/pixel/PixelDefender.tscn index 711e89f..29c7674 100644 --- a/scenes/levels/pixel/PixelDefender.tscn +++ b/scenes/levels/pixel/PixelDefender.tscn @@ -13,4 +13,5 @@ script = ExtResource( 1 ) position = Vector2( -432.818, -39.5735 ) [node name="Enemies" type="Node2D" parent="."] + [connection signal="area_shape_entered" from="spaceship" to="." method="_on_spaceship_area_shape_entered"] diff --git a/scenes/levels/puzzle/puzzle.gd b/scenes/levels/puzzle/puzzle.gd index c23b3a2..982bb29 100644 --- a/scenes/levels/puzzle/puzzle.gd +++ b/scenes/levels/puzzle/puzzle.gd @@ -30,6 +30,13 @@ func _ready(): func _position_from_index(idx): return Vector2(idx % dim, int(idx / dim)) +func _unhandled_input(event): + if running and event is InputEventKey and event.pressed and event.scancode == KEY_K: + order = range(dim*dim) + _render_state() + _check_state() + + func on_anybutton_click(piece_name): var pos = _button_position(piece_name) _do_push(pos, _hole_position()) diff --git a/scenes/levels/typeracer.gd b/scenes/levels/typeracer.gd index 429dc7a..c17e1bc 100644 --- a/scenes/levels/typeracer.gd +++ b/scenes/levels/typeracer.gd @@ -29,6 +29,7 @@ func eval(): if $Label.text.replace('\r\n', '\n').replace('\r', '\n') == $TextEdit.text.replace('\r\n', '\n').replace('\r', '\n'): $TextEdit.readonly = true $Button.disabled = true + $Incorrect.visible = false finish_level() else: lose_heart() @@ -40,6 +41,7 @@ func eval_corr(): if $Label.text.replace('\r\n', '\n').replace('\r', '\n') == $TextEdit.text.replace('\r\n', '\n').replace('\r', '\n'): $TextEdit.readonly = true $Button.disabled = true + $Incorrect.visible = false finish_level() func _on_Button_on_click(): diff --git a/scenes/levels/typeracer.tscn b/scenes/levels/typeracer.tscn index b8e0b9c..3556dc3 100644 --- a/scenes/levels/typeracer.tscn +++ b/scenes/levels/typeracer.tscn @@ -59,5 +59,6 @@ text = "The text you wrote is not exactely correct" __meta__ = { "_edit_use_anchors_": false } + [connection signal="text_changed" from="TextEdit" to="." method="_on_TextEdit_text_changed"] [connection signal="on_click" from="Button" to="." method="_on_Button_on_click"] diff --git a/scenes/pause.gd b/scenes/pause.gd index 0115b1a..9820845 100644 --- a/scenes/pause.gd +++ b/scenes/pause.gd @@ -14,6 +14,12 @@ func _on_Resume_on_click(): get_tree().paused = false emit_signal("unpause") +func _unhandled_input(event): + if event is InputEventKey and event.pressed and event.scancode == KEY_ESCAPE: + if pause_menu.visible: + _on_Resume_on_click() + else: + pause() func _on_Main_Menu_on_click(): get_tree().paused = false |