develop #50

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

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/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/botonreiniciar.gdns" type="Script" id=3] [ext_resource path="res://GUI/botonreiniciar.gdns" type="Script" id=3]
[ext_resource path="res://assets/sounds/died.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 = "REINICIAR" text = "REINICIAR"
[node name="GameOverMusic" type="AudioStreamPlayer" parent="."]
stream = ExtResource( 4 )
volume_db = -23.524
[connection signal="visibility_changed" from="." to="." method="_play_music"]
[connection signal="pressed" from="Control/RestartButton" to="." method="_on_restart_button_pressed"] [connection signal="pressed" from="Control/RestartButton" to="." method="_on_restart_button_pressed"]

BIN
godot/assets/music/Magic Fx 7.ogg (Stored with Git LFS) Normal file

Binary file not shown.

View File

@ -0,0 +1,15 @@
[remap]
importer="ogg_vorbis"
type="AudioStreamOGGVorbis"
path="res://.import/Magic Fx 7.ogg-8a3ae422bac9ed88f48079377b8e81ff.oggstr"
[deps]
source_file="res://assets/music/Magic Fx 7.ogg"
dest_files=[ "res://.import/Magic Fx 7.ogg-8a3ae422bac9ed88f48079377b8e81ff.oggstr" ]
[params]
loop=true
loop_offset=0

View File

@ -52,4 +52,4 @@ collision_mask = 24
[node name="Jump" type="AudioStreamPlayer" parent="Sounds"] [node name="Jump" type="AudioStreamPlayer" parent="Sounds"]
stream = ExtResource( 8 ) stream = ExtResource( 8 )
volume_db = -45.0 volume_db = -23.953

View File

@ -1,9 +1,10 @@
[gd_scene load_steps=10 format=2] [gd_scene load_steps=11 format=2]
[ext_resource path="res://assets/coin.png" type="Texture" id=1] [ext_resource path="res://assets/coin.png" type="Texture" id=1]
[ext_resource path="res://state_machine/StateMachine.gdns" type="Script" id=2] [ext_resource path="res://state_machine/StateMachine.gdns" type="Script" id=2]
[ext_resource path="res://collectables/coin/states/CoinNotCollected.gdns" type="Script" id=3] [ext_resource path="res://collectables/coin/states/CoinNotCollected.gdns" type="Script" id=3]
[ext_resource path="res://collectables/coin/states/CoinCollected.gdns" type="Script" id=4] [ext_resource path="res://collectables/coin/states/CoinCollected.gdns" type="Script" id=4]
[ext_resource path="res://assets/sounds/coin.wav" type="AudioStream" id=5]
[sub_resource type="CircleShape2D" id=1] [sub_resource type="CircleShape2D" id=1]
radius = 6.0 radius = 6.0
@ -67,5 +68,9 @@ script = ExtResource( 4 )
[node name="AnimationPlayer" type="AnimationPlayer" parent="."] [node name="AnimationPlayer" type="AnimationPlayer" parent="."]
anims/jump = SubResource( 5 ) anims/jump = SubResource( 5 )
[node name="CoinCollectedSound" type="AudioStreamPlayer" parent="."]
stream = ExtResource( 5 )
volume_db = -6.19
[connection signal="body_entered" from="." to="StateMachine/CoinNotCollected" method="_on_body_entered" flags=6] [connection signal="body_entered" from="." to="StateMachine/CoinNotCollected" method="_on_body_entered" flags=6]
[connection signal="animation_finished" from="AnimationPlayer" to="StateMachine/CoinCollected" method="_on_animation_finished" flags=6] [connection signal="animation_finished" from="AnimationPlayer" to="StateMachine/CoinCollected" method="_on_animation_finished" flags=6]

View File

@ -1,4 +1,4 @@
[gd_scene load_steps=8 format=2] [gd_scene load_steps=9 format=2]
[ext_resource path="res://CameraLimit.gdns" type="Script" id=1] [ext_resource path="res://CameraLimit.gdns" type="Script" id=1]
[ext_resource path="res://characters/player/Player.tscn" type="PackedScene" id=2] [ext_resource path="res://characters/player/Player.tscn" type="PackedScene" id=2]
@ -6,6 +6,7 @@
[ext_resource path="res://assets/backgrounds/mountains.png" type="Texture" id=4] [ext_resource path="res://assets/backgrounds/mountains.png" type="Texture" id=4]
[ext_resource path="res://collectables/coin/Coin.tscn" type="PackedScene" id=5] [ext_resource path="res://collectables/coin/Coin.tscn" type="PackedScene" id=5]
[ext_resource path="res://hud/CoinHUD.tscn" type="PackedScene" id=6] [ext_resource path="res://hud/CoinHUD.tscn" type="PackedScene" id=6]
[ext_resource path="res://assets/music/Magic Fx 7.ogg" type="AudioStream" id=7]
[ext_resource path="res://goal/Goal.tscn" type="PackedScene" id=8] [ext_resource path="res://goal/Goal.tscn" type="PackedScene" id=8]
[node name="Prototype" type="Node2D"] [node name="Prototype" type="Node2D"]
@ -51,9 +52,17 @@ script = ExtResource( 1 )
[node name="coin" parent="Coins" instance=ExtResource( 5 )] [node name="coin" parent="Coins" instance=ExtResource( 5 )]
position = Vector2( 72, 450 ) position = Vector2( 72, 450 )
[node name="AnimatedSprite" parent="Coins/coin" index="1"]
frame = 0
[node name="coin2" parent="Coins" instance=ExtResource( 5 )] [node name="coin2" parent="Coins" instance=ExtResource( 5 )]
position = Vector2( 234, 450 ) position = Vector2( 234, 450 )
[node name="Goal" parent="." instance=ExtResource( 8 )] [node name="Goal" parent="." instance=ExtResource( 8 )]
[node name="BGM" type="AudioStreamPlayer" parent="."]
stream = ExtResource( 7 )
volume_db = -29.714
autoplay = true
[editable path="Coins/coin"] [editable path="Coins/coin"]

View File

@ -2,6 +2,7 @@
#include "Event.h" #include "Event.h"
#include <AudioStreamPlayer.hpp>
#include <AnimationPlayer.hpp> #include <AnimationPlayer.hpp>
void alai::CoinCollected::_register_methods() void alai::CoinCollected::_register_methods()
@ -32,7 +33,8 @@ void alai::CoinCollected::_state_enter()
auto animation_player = Object::cast_to<godot::AnimationPlayer>(node); auto animation_player = Object::cast_to<godot::AnimationPlayer>(node);
animation_player->play("jump"); animation_player->play("jump");
} }
auto coin_collected_sound = get_parent()->get_node<godot::AudioStreamPlayer>("CoinCollectedSound");
coin_collected_sound->play();
} }
void alai::CoinCollected::_state_exit() void alai::CoinCollected::_state_exit()

View File

@ -7,6 +7,8 @@
#include <Resource.hpp> #include <Resource.hpp>
#include <SceneTree.hpp> #include <SceneTree.hpp>
#include <Viewport.hpp> #include <Viewport.hpp>
#include <AudioStreamPlayer.hpp>
#include <VisibilityNotifier.hpp>
void alai::GameOverScreen::_register_methods() void alai::GameOverScreen::_register_methods()
{ {
@ -14,6 +16,7 @@ void alai::GameOverScreen::_register_methods()
register_method("_ready", &GameOverScreen::_ready); register_method("_ready", &GameOverScreen::_ready);
register_method("connect_signal", &GameOverScreen::connect_signal); register_method("connect_signal", &GameOverScreen::connect_signal);
register_method("_on_player_died", &GameOverScreen::_on_player_died); register_method("_on_player_died", &GameOverScreen::_on_player_died);
register_method("_play music", &GameOverScreen::_play_music);
} }
alai::GameOverScreen::GameOverScreen() alai::GameOverScreen::GameOverScreen()
@ -29,9 +32,11 @@ void alai::GameOverScreen::_init()
_resource_loader = godot::ResourceLoader::get_singleton(); _resource_loader = godot::ResourceLoader::get_singleton();
} }
void alai::GameOverScreen::_ready() void alai::GameOverScreen::_ready()
{ {
connect_signal(); connect_signal();
} }
void alai::GameOverScreen::_on_restart_button_pressed() void alai::GameOverScreen::_on_restart_button_pressed()
@ -85,3 +90,20 @@ void alai::GameOverScreen::connect_signal()
auto event = get_node<alai::Event>("/root/Event"); auto event = get_node<alai::Event>("/root/Event");
event->connect("player_died", this, "_on_player_died"); event->connect("player_died", this, "_on_player_died");
} }
void alai::GameOverScreen::_play_music()
{
if (this->is_on_screen() == true)
{
auto game_over_sound = get_node<godot::AudioStreamPlayer>("GameOverMusic");
game_over_sound->play();
}
else
{
auto game_over_sound = get_node<godot::AudioStreamPlayer>("GameOverMusic");
game_over_sound->stop();
}
}

View File

@ -5,6 +5,7 @@
#include <Godot.hpp> #include <Godot.hpp>
#include <ResourceLoader.hpp> #include <ResourceLoader.hpp>
namespace alai namespace alai
{ {
/** /**
@ -53,6 +54,7 @@ namespace alai
void _on_player_died(); void _on_player_died();
void _on_restart_button_pressed(); void _on_restart_button_pressed();
void connect_signal(); void connect_signal();
void _play_music();
}; };
} }