fix sounds when jumping on enemy

This commit is contained in:
Chris Cromer 2022-08-29 20:17:12 -04:00
parent e5d92c8267
commit a34ca72577
Signed by: cromer
GPG Key ID: FA91071797BEEEC2

View File

@ -130,8 +130,13 @@ void alai::player::Player::_physics_process(float delta)
WARN_PRINT("Enemies not found!"); WARN_PRINT("Enemies not found!");
dup->queue_free(); dup->queue_free();
}*/ }*/
auto jump_sound = get_parent()->get_node<godot::AudioStreamPlayer>("Sounds/Jump"); auto jump_sound = get_node<godot::AudioStreamPlayer>("Sounds/Jump");
if (jump_sound != nullptr) {
jump_sound->play(); jump_sound->play();
}
else {
WARN_PRINT("Player jump sound not found!");
}
velocity.y = -get_bounce_force(); 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)) else if (collider->is_in_group("enemy") && (collider->is_in_group("rideable") && godot::Vector2::DOWN.dot(collision->get_normal()) > 0))
@ -168,14 +173,6 @@ void alai::player::Player::_physics_process(float delta)
{ {
auto event = get_node<alai::Event>("/root/Event"); auto event = get_node<alai::Event>("/root/Event");
event->emit_signal("player_died"); event->emit_signal("player_died");
/*if (get_parent()->get_class() == "TileMap")
{
auto error = get_tree()->change_scene("res://Main.tscn");
if (error != godot::Error::OK)
{
ERR_PRINT(godot::String().num((int) error) + " Could not load scene!");
}
}*/
} }
} }
@ -273,9 +270,11 @@ godot::Vector2 alai::player::Player::get_velocity()
void alai::player::Player::_on_player_touched() void alai::player::Player::_on_player_touched()
{ {
auto error = get_tree()->change_scene("res://Main.tscn"); /*auto error = get_tree()->change_scene("res://Main.tscn");
if (error != godot::Error::OK) if (error != godot::Error::OK)
{ {
ERR_PRINT(godot::String().num((int) error) + " Could not load scene!"); ERR_PRINT(godot::String().num((int) error) + " Could not load scene!");
} }*/
auto event = get_node<alai::Event>("/root/Event");
event->emit_signal("player_died");
} }