Merge pull request 'feature/music' (#48) from feature/music into develop
Reviewed-on: #48
This commit is contained in:
commit
28ba710581
BIN
godot/assets/sounds/victory.wav
(Stored with Git LFS)
Normal file
BIN
godot/assets/sounds/victory.wav
(Stored with Git LFS)
Normal file
Binary file not shown.
23
godot/assets/sounds/victory.wav.import
Normal file
23
godot/assets/sounds/victory.wav.import
Normal 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
|
@ -48,7 +48,7 @@ text = "REINICIAR"
|
|||||||
|
|
||||||
[node name="GameOverMusic" type="AudioStreamPlayer" parent="."]
|
[node name="GameOverMusic" type="AudioStreamPlayer" parent="."]
|
||||||
stream = ExtResource( 4 )
|
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"]
|
[connection signal="pressed" from="Control/RestartButton" to="." method="_on_restart_button_pressed"]
|
||||||
|
@ -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/PixelOperator8.ttf" type="DynamicFontData" id=1]
|
||||||
[ext_resource path="res://assets/fonts/ttf/PixelOperatorHB8.ttf" type="DynamicFontData" id=2]
|
[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://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]
|
[sub_resource type="DynamicFont" id=1]
|
||||||
size = 50
|
size = 50
|
||||||
@ -45,4 +46,9 @@ custom_fonts/font = SubResource( 2 )
|
|||||||
custom_styles/hover = SubResource( 3 )
|
custom_styles/hover = SubResource( 3 )
|
||||||
text = "SALIR"
|
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"]
|
[connection signal="pressed" from="Control/QuitButton" to="." method="_on_quit_button_pressed"]
|
||||||
|
@ -30,10 +30,14 @@ void alai::CoinCounter::_ready()
|
|||||||
event->connect("coin_collected", this, "_on_coin_collected");
|
event->connect("coin_collected", this, "_on_coin_collected");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void alai::CoinCounter::_on_coin_collected(int amount)
|
void alai::CoinCounter::_on_coin_collected(int amount)
|
||||||
{
|
{
|
||||||
coins = coins + amount;
|
coins = coins + amount;
|
||||||
|
if (coins >= 100)
|
||||||
|
{
|
||||||
|
auto extra = coins - 100;
|
||||||
|
coins = extra;
|
||||||
|
}
|
||||||
godot::String coin_string = godot::String();
|
godot::String coin_string = godot::String();
|
||||||
if (coins <= 9)
|
if (coins <= 9)
|
||||||
{
|
{
|
||||||
|
@ -15,7 +15,7 @@ namespace alai
|
|||||||
GODOT_CLASS(CoinCounter, godot::Label)
|
GODOT_CLASS(CoinCounter, godot::Label)
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int coins;
|
uint8_t coins;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
|
@ -16,7 +16,7 @@ void alai::GameOverScreen::_register_methods()
|
|||||||
godot::register_method("restart_game", &GameOverScreen::restart_game);
|
godot::register_method("restart_game", &GameOverScreen::restart_game);
|
||||||
godot::register_method("connect_signal", &GameOverScreen::connect_signal);
|
godot::register_method("connect_signal", &GameOverScreen::connect_signal);
|
||||||
godot::register_method("_on_player_died", &GameOverScreen::_on_player_died);
|
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()
|
alai::GameOverScreen::GameOverScreen()
|
||||||
@ -96,6 +96,15 @@ void alai::GameOverScreen::connect_signal()
|
|||||||
event->connect("player_died", this, "_on_player_died");
|
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();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -55,7 +55,7 @@ namespace alai
|
|||||||
void _on_restart_button_pressed();
|
void _on_restart_button_pressed();
|
||||||
void restart_game();
|
void restart_game();
|
||||||
void connect_signal();
|
void connect_signal();
|
||||||
void _play_music();
|
void _on_visibility_changed();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
#include "Event.h"
|
#include "Event.h"
|
||||||
|
|
||||||
|
#include <AudioStreamPlayer.hpp>
|
||||||
#include <SceneTree.hpp>
|
#include <SceneTree.hpp>
|
||||||
#include <Viewport.hpp>
|
#include <Viewport.hpp>
|
||||||
|
|
||||||
@ -11,6 +12,7 @@ void alai::GameWonScreen::_register_methods()
|
|||||||
godot::register_method("connect_signal", &GameWonScreen::connect_signal);
|
godot::register_method("connect_signal", &GameWonScreen::connect_signal);
|
||||||
godot::register_method("_on_player_won", &GameWonScreen::_on_player_won);
|
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_quit_button_pressed", &GameWonScreen::_on_quit_button_pressed);
|
||||||
|
godot::register_method("_on_visibility_changed", &GameWonScreen::_on_visibility_changed);
|
||||||
}
|
}
|
||||||
|
|
||||||
alai::GameWonScreen::GameWonScreen()
|
alai::GameWonScreen::GameWonScreen()
|
||||||
@ -64,3 +66,16 @@ void alai::GameWonScreen::connect_signal()
|
|||||||
auto event = get_node<alai::Event>("/root/Event");
|
auto event = get_node<alai::Event>("/root/Event");
|
||||||
event->connect("player_won", this, "_on_player_won");
|
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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -45,6 +45,7 @@ namespace alai
|
|||||||
void _on_player_won();
|
void _on_player_won();
|
||||||
void _on_quit_button_pressed();
|
void _on_quit_button_pressed();
|
||||||
void connect_signal();
|
void connect_signal();
|
||||||
|
void _on_visibility_changed();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user