develop #50

Merged
cromer merged 47 commits from develop into master 2022-09-02 00:37:34 -04:00
10 changed files with 69 additions and 8 deletions
Showing only changes of commit 28ba710581 - Show all commits

BIN
godot/assets/sounds/victory.wav (Stored with Git LFS) Normal file

Binary file not shown.

View File

@ -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

View File

@ -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"]

View File

@ -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"]

View File

@ -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)
{

View File

@ -15,7 +15,7 @@ namespace alai
GODOT_CLASS(CoinCounter, godot::Label)
private:
int coins;
uint8_t coins;
public:
/**

View File

@ -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<godot::AudioStreamPlayer>("GameOverMusic");
if (is_visible())
{
gameoversound->play();
}
else
{
gameoversound->stop();
}
}

View File

@ -55,7 +55,7 @@ namespace alai
void _on_restart_button_pressed();
void restart_game();
void connect_signal();
void _play_music();
void _on_visibility_changed();
};
}

View File

@ -2,6 +2,7 @@
#include "Event.h"
#include <AudioStreamPlayer.hpp>
#include <SceneTree.hpp>
#include <Viewport.hpp>
@ -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<alai::Event>("/root/Event");
event->connect("player_won", this, "_on_player_won");
}
void alai::GameWonScreen::_on_visibility_changed()
{
auto victorysound = get_node<godot::AudioStreamPlayer>("VictorySound");
if (is_visible())
{
victorysound->play();
}
else
{
victorysound->stop();
}
}

View File

@ -45,6 +45,7 @@ namespace alai
void _on_player_won();
void _on_quit_button_pressed();
void connect_signal();
void _on_visibility_changed();
};
}