Merge pull request 'develop' (#40) from develop into master
Reviewed-on: #40
This commit is contained in:
commit
066012bd1b
@ -100,8 +100,16 @@ void alai::player::Player::_physics_process(float delta)
|
|||||||
snap_vector = godot::Vector2::DOWN * 20.0;
|
snap_vector = godot::Vector2::DOWN * 20.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
auto is_on_platform = false;
|
||||||
auto platform_detector = get_node<godot::RayCast2D>("PlatformDetector");
|
auto platform_detector = get_node<godot::RayCast2D>("PlatformDetector");
|
||||||
auto is_on_platform = platform_detector->is_colliding();
|
if (platform_detector != nullptr)
|
||||||
|
{
|
||||||
|
is_on_platform = platform_detector->is_colliding();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
WARN_PRINT("PlatformDetector not found!");
|
||||||
|
}
|
||||||
|
|
||||||
velocity = move_and_slide_with_snap(velocity, snap_vector, godot::Vector2::UP, !is_on_platform, 4, 0.9, false);
|
velocity = move_and_slide_with_snap(velocity, snap_vector, godot::Vector2::UP, !is_on_platform, 4, 0.9, false);
|
||||||
//velocity = move_and_slide(velocity, Vector2::UP, !is_on_platform);
|
//velocity = move_and_slide(velocity, Vector2::UP, !is_on_platform);
|
||||||
@ -130,8 +138,15 @@ 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))
|
||||||
@ -146,6 +161,8 @@ void alai::player::Player::_physics_process(float delta)
|
|||||||
|
|
||||||
// Clamp the player's position inside the camera's limits
|
// Clamp the player's position inside the camera's limits
|
||||||
auto camera = get_node<godot::Camera2D>("Camera2D");
|
auto camera = get_node<godot::Camera2D>("Camera2D");
|
||||||
|
if (camera != nullptr)
|
||||||
|
{
|
||||||
auto position = get_global_position();
|
auto position = get_global_position();
|
||||||
auto sprite_node = get_node<godot::AnimatedSprite>("AnimatedSprite");
|
auto sprite_node = get_node<godot::AnimatedSprite>("AnimatedSprite");
|
||||||
if (sprite_node != nullptr)
|
if (sprite_node != nullptr)
|
||||||
@ -159,6 +176,11 @@ void alai::player::Player::_physics_process(float delta)
|
|||||||
position.y = godot::Math::clamp((float) position.y, (float) camera->get_limit(1), (float) camera->get_limit(3));
|
position.y = godot::Math::clamp((float) position.y, (float) camera->get_limit(1), (float) camera->get_limit(3));
|
||||||
}
|
}
|
||||||
set_global_position(position);
|
set_global_position(position);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
WARN_PRINT("Camera node not found!");
|
||||||
|
}
|
||||||
|
|
||||||
// If the player is off screen reload the scene
|
// If the player is off screen reload the scene
|
||||||
auto notifier = get_node<godot::VisibilityNotifier2D>("Camera2D/VisibilityNotifier2D");
|
auto notifier = get_node<godot::VisibilityNotifier2D>("Camera2D/VisibilityNotifier2D");
|
||||||
@ -168,15 +190,11 @@ 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!");
|
|
||||||
}
|
}
|
||||||
}*/
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
WARN_PRINT("Visibility notifier not found!");
|
||||||
}
|
}
|
||||||
|
|
||||||
auto state = get_node("StateMachine")->get_child(0);
|
auto state = get_node("StateMachine")->get_child(0);
|
||||||
@ -273,9 +291,6 @@ 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 event = get_node<alai::Event>("/root/Event");
|
||||||
if (error != godot::Error::OK)
|
event->emit_signal("player_died");
|
||||||
{
|
|
||||||
ERR_PRINT(godot::String().num((int) error) + " Could not load scene!");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user