Merge pull request 'feature/PROTOTYPE_R_SOUNDS' (#45) from feature/PROTOTYPE_R_SOUNDS into feature/Prototype_R_LEVEL

Reviewed-on: #45
This commit is contained in:
Martin Araneda 2022-09-01 15:59:13 -04:00
commit 46f32da8ff
11 changed files with 73 additions and 4 deletions

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/botonreiniciar.gdns" type="Script" id=3]
[ext_resource path="res://assets/sounds/died.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 = "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"]

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,3 +52,4 @@ collision_mask = 24
[node name="Jump" type="AudioStreamPlayer" parent="Sounds"]
stream = ExtResource( 8 )
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://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/CoinCollected.gdns" type="Script" id=4]
[ext_resource path="res://assets/sounds/coin.wav" type="AudioStream" id=5]
[sub_resource type="CircleShape2D" id=1]
radius = 6.0
@ -67,5 +68,9 @@ script = ExtResource( 4 )
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
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="animation_finished" from="AnimationPlayer" to="StateMachine/CoinCollected" method="_on_animation_finished" flags=6]

View File

@ -45,4 +45,5 @@ script = ExtResource( 1 )
[node name="AudioStreamPlayer" type="AudioStreamPlayer" parent="."]
pause_mode = 2
stream = ExtResource( 5 )
volume_db = -35.0
script = ExtResource( 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://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://collectables/coin/Coin.tscn" type="PackedScene" id=5]
[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]
[node name="Prototype" type="Node2D"]
@ -50,9 +51,17 @@ script = ExtResource( 1 )
[node name="coin" parent="Coins" instance=ExtResource( 5 )]
position = Vector2( 72, 450 )
[node name="AnimatedSprite" parent="Coins/coin" index="1"]
frame = 0
[node name="coin2" parent="Coins" instance=ExtResource( 5 )]
position = Vector2( 234, 450 )
[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"]

View File

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

View File

@ -7,6 +7,8 @@
#include <Resource.hpp>
#include <SceneTree.hpp>
#include <Viewport.hpp>
#include <AudioStreamPlayer.hpp>
#include <VisibilityNotifier.hpp>
void alai::GameOverScreen::_register_methods()
{
@ -14,6 +16,7 @@ void alai::GameOverScreen::_register_methods()
register_method("_ready", &GameOverScreen::_ready);
register_method("connect_signal", &GameOverScreen::connect_signal);
register_method("_on_player_died", &GameOverScreen::_on_player_died);
register_method("_play music", &GameOverScreen::_play_music);
}
alai::GameOverScreen::GameOverScreen()
@ -29,9 +32,11 @@ void alai::GameOverScreen::_init()
_resource_loader = godot::ResourceLoader::get_singleton();
}
void alai::GameOverScreen::_ready()
{
connect_signal();
}
void alai::GameOverScreen::_on_restart_button_pressed()
@ -86,3 +91,20 @@ void alai::GameOverScreen::connect_signal()
auto event = get_node<alai::Event>("/root/Event");
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 <ResourceLoader.hpp>
namespace alai
{
/**
@ -53,6 +54,7 @@ namespace alai
void _on_player_died();
void _on_restart_button_pressed();
void connect_signal();
void _play_music();
};
}

View File

@ -2,6 +2,7 @@
#include "Event.h"
#include <AudioStreamPlayer.hpp>
#include <Camera2D.hpp>
#include <KinematicCollision2D.hpp>
#include <RayCast2D.hpp>
@ -129,6 +130,8 @@ void alai::player::Player::_physics_process(float delta)
WARN_PRINT("Enemies not found!");
dup->queue_free();
}*/
auto jump_sound = get_parent()->get_node<godot::AudioStreamPlayer>("Sounds/Jump");
jump_sound->play();
velocity.y = -get_bounce_force();
}
else if (collider->is_in_group("enemy") && (collider->is_in_group("rideable") && godot::Vector2::DOWN.dot(collision->get_normal()) > 0))