From 2c5d3d9afec8f0300fdd39941f5052f462a41542 Mon Sep 17 00:00:00 2001 From: Martin Araneda Date: Thu, 1 Sep 2022 23:20:53 -0400 Subject: [PATCH 1/5] validation over 100 coins --- src/coin/CoinCounter.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/coin/CoinCounter.cpp b/src/coin/CoinCounter.cpp index da39b39..e29280b 100644 --- a/src/coin/CoinCounter.cpp +++ b/src/coin/CoinCounter.cpp @@ -30,10 +30,14 @@ void alai::CoinCounter::_ready() event->connect("coin_collected", this, "_on_coin_collected"); } - void alai::CoinCounter::_on_coin_collected(int amount) { coins = coins + amount; + if (coins >= 100) + { + auto extra = coins - 100; + coins = extra; + } godot::String coin_string = godot::String(); if (coins <= 9) { From a8e364415c4f681fbd29b36f35e710c23028c75d Mon Sep 17 00:00:00 2001 From: Martin Araneda Date: Thu, 1 Sep 2022 23:21:30 -0400 Subject: [PATCH 2/5] changed coin type format to avoid negatives --- src/coin/CoinCounter.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/coin/CoinCounter.h b/src/coin/CoinCounter.h index 8702887..e04f5fa 100644 --- a/src/coin/CoinCounter.h +++ b/src/coin/CoinCounter.h @@ -15,7 +15,7 @@ namespace alai GODOT_CLASS(CoinCounter, godot::Label) private: - int coins; + uint8_t coins; public: /** From e62acd3ab1932a769092b2796fe06d8500afd639 Mon Sep 17 00:00:00 2001 From: Martin Araneda Date: Thu, 1 Sep 2022 23:22:10 -0400 Subject: [PATCH 3/5] final changes to music --- godot/gui/GameOver.tscn | 4 ++-- src/gui/game_over/GameOverScreen.cpp | 13 +++++++++++-- src/gui/game_over/GameOverScreen.h | 2 +- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/godot/gui/GameOver.tscn b/godot/gui/GameOver.tscn index 56c19a8..08d8f03 100644 --- a/godot/gui/GameOver.tscn +++ b/godot/gui/GameOver.tscn @@ -48,7 +48,7 @@ text = "REINICIAR" [node name="GameOverMusic" type="AudioStreamPlayer" parent="."] stream = ExtResource( 4 ) -volume_db = -23.524 +volume_db = -25.0 -[connection signal="visibility_changed" from="." to="." method="_play_music"] +[connection signal="visibility_changed" from="." to="." method="_on_visibility_changed"] [connection signal="pressed" from="Control/RestartButton" to="." method="_on_restart_button_pressed"] diff --git a/src/gui/game_over/GameOverScreen.cpp b/src/gui/game_over/GameOverScreen.cpp index 622a032..9dcdf47 100644 --- a/src/gui/game_over/GameOverScreen.cpp +++ b/src/gui/game_over/GameOverScreen.cpp @@ -16,7 +16,7 @@ void alai::GameOverScreen::_register_methods() godot::register_method("restart_game", &GameOverScreen::restart_game); godot::register_method("connect_signal", &GameOverScreen::connect_signal); godot::register_method("_on_player_died", &GameOverScreen::_on_player_died); - godot::register_method("_play_music", &GameOverScreen::_play_music); + godot::register_method("_on_visibility_changed", &GameOverScreen::_on_visibility_changed); } alai::GameOverScreen::GameOverScreen() @@ -96,6 +96,15 @@ void alai::GameOverScreen::connect_signal() event->connect("player_died", this, "_on_player_died"); } -void alai::GameOverScreen::_play_music() +void alai::GameOverScreen::_on_visibility_changed() { + auto gameoversound = get_node("GameOverMusic"); + if (is_visible()) + { + gameoversound->play(); + } + else + { + gameoversound->stop(); + } } diff --git a/src/gui/game_over/GameOverScreen.h b/src/gui/game_over/GameOverScreen.h index 3fb679c..0dc7226 100644 --- a/src/gui/game_over/GameOverScreen.h +++ b/src/gui/game_over/GameOverScreen.h @@ -55,7 +55,7 @@ namespace alai void _on_restart_button_pressed(); void restart_game(); void connect_signal(); - void _play_music(); + void _on_visibility_changed(); }; } From e7a1b4f2f82a743ec85850d5d02393703016282f Mon Sep 17 00:00:00 2001 From: Martin Araneda Date: Thu, 1 Sep 2022 23:22:37 -0400 Subject: [PATCH 4/5] Added music to VictoryScreen --- godot/gui/GameWon.tscn | 8 +++++++- src/gui/game_won/GameWonScreen.cpp | 15 +++++++++++++++ src/gui/game_won/GameWonScreen.h | 1 + 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/godot/gui/GameWon.tscn b/godot/gui/GameWon.tscn index 49889fc..f91c385 100644 --- a/godot/gui/GameWon.tscn +++ b/godot/gui/GameWon.tscn @@ -1,8 +1,9 @@ -[gd_scene load_steps=7 format=2] +[gd_scene load_steps=8 format=2] [ext_resource path="res://assets/fonts/ttf/PixelOperator8.ttf" type="DynamicFontData" id=1] [ext_resource path="res://assets/fonts/ttf/PixelOperatorHB8.ttf" type="DynamicFontData" id=2] [ext_resource path="res://gui/GameWonScreen.gdns" type="Script" id=3] +[ext_resource path="res://assets/sounds/victory.wav" type="AudioStream" id=4] [sub_resource type="DynamicFont" id=1] size = 50 @@ -45,4 +46,9 @@ custom_fonts/font = SubResource( 2 ) custom_styles/hover = SubResource( 3 ) text = "SALIR" +[node name="VictorySound" type="AudioStreamPlayer" parent="."] +stream = ExtResource( 4 ) +volume_db = -18.0 + +[connection signal="visibility_changed" from="." to="." method="_on_visibility_changed"] [connection signal="pressed" from="Control/QuitButton" to="." method="_on_quit_button_pressed"] diff --git a/src/gui/game_won/GameWonScreen.cpp b/src/gui/game_won/GameWonScreen.cpp index f51822e..81ddc6d 100644 --- a/src/gui/game_won/GameWonScreen.cpp +++ b/src/gui/game_won/GameWonScreen.cpp @@ -2,6 +2,7 @@ #include "Event.h" +#include #include #include @@ -11,6 +12,7 @@ void alai::GameWonScreen::_register_methods() godot::register_method("connect_signal", &GameWonScreen::connect_signal); godot::register_method("_on_player_won", &GameWonScreen::_on_player_won); godot::register_method("_on_quit_button_pressed", &GameWonScreen::_on_quit_button_pressed); + godot::register_method("_on_visibility_changed", &GameWonScreen::_on_visibility_changed); } alai::GameWonScreen::GameWonScreen() @@ -64,3 +66,16 @@ void alai::GameWonScreen::connect_signal() auto event = get_node("/root/Event"); event->connect("player_won", this, "_on_player_won"); } + +void alai::GameWonScreen::_on_visibility_changed() +{ + auto victorysound = get_node("VictorySound"); + if (is_visible()) + { + victorysound->play(); + } + else + { + victorysound->stop(); + } +} diff --git a/src/gui/game_won/GameWonScreen.h b/src/gui/game_won/GameWonScreen.h index 987b7a1..683e554 100644 --- a/src/gui/game_won/GameWonScreen.h +++ b/src/gui/game_won/GameWonScreen.h @@ -45,6 +45,7 @@ namespace alai void _on_player_won(); void _on_quit_button_pressed(); void connect_signal(); + void _on_visibility_changed(); }; } From 866944b784168ec74130fbbab8b8d6953a243944 Mon Sep 17 00:00:00 2001 From: Martin Araneda Date: Thu, 1 Sep 2022 23:22:56 -0400 Subject: [PATCH 5/5] Added victory sound to assets --- godot/assets/sounds/victory.wav | 3 +++ godot/assets/sounds/victory.wav.import | 23 +++++++++++++++++++++++ 2 files changed, 26 insertions(+) create mode 100644 godot/assets/sounds/victory.wav create mode 100644 godot/assets/sounds/victory.wav.import diff --git a/godot/assets/sounds/victory.wav b/godot/assets/sounds/victory.wav new file mode 100644 index 0000000..4287414 --- /dev/null +++ b/godot/assets/sounds/victory.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a5c247f96d1a500806f31f8efd2d31a05c2422416afe3379b50b67cb04a7e810 +size 930948 diff --git a/godot/assets/sounds/victory.wav.import b/godot/assets/sounds/victory.wav.import new file mode 100644 index 0000000..557cd90 --- /dev/null +++ b/godot/assets/sounds/victory.wav.import @@ -0,0 +1,23 @@ +[remap] + +importer="wav" +type="AudioStreamSample" +path="res://.import/victory.wav-652e970b8418d2fc380cb882ddb39b3d.sample" + +[deps] + +source_file="res://assets/sounds/victory.wav" +dest_files=[ "res://.import/victory.wav-652e970b8418d2fc380cb882ddb39b3d.sample" ] + +[params] + +force/8_bit=false +force/mono=false +force/max_rate=false +force/max_rate_hz=44100 +edit/trim=false +edit/normalize=false +edit/loop_mode=0 +edit/loop_begin=0 +edit/loop_end=-1 +compress/mode=0