Skip to content

Commit

Permalink
Fix airship descent mid-move
Browse files Browse the repository at this point in the history
Part of EasyRPG#1429. RPG_RT allows you to land the airship
from an event while the player/airship is moving as part of a move
route.

In RPG_RT, this causes graphical glitches as the descent causes
the airship sprite to warp to the tile and change direction before
finishing its walk animation. This set of changes fixes those
graphical glitches in Player while still allowing the same
event behavior to occur.
  • Loading branch information
fmatthew5876 committed Feb 6, 2019
1 parent 49cc3b4 commit 9acfeda
Showing 1 changed file with 33 additions and 19 deletions.
52 changes: 33 additions & 19 deletions src/game_vehicle.cpp
Expand Up @@ -202,22 +202,34 @@ void Game_Vehicle::GetOff() {
} else {
Main_Data::game_player->UnboardingFinished();
}
SetDirection(Left);
SetSpriteDirection(Left);
// Get off airship can be trigger while airship is moving. Don't break the animation
// until its finished.
if (type != Airship || (!IsMoving() && !IsJumping())) {
SetDirection(Left);
SetSpriteDirection(Left);
}
}

bool Game_Vehicle::IsInUse() const {
return Main_Data::game_player->GetVehicle() == this;
}

void Game_Vehicle::SyncWithPlayer() {
if (!IsInUse() || IsAscending() || IsDescending())
if (!IsInUse()) {
return;
}
SetX(Main_Data::game_player->GetX());
SetY(Main_Data::game_player->GetY());
SetRemainingStep(Main_Data::game_player->GetRemainingStep());
SetDirection(Main_Data::game_player->GetDirection());
SetSpriteDirection(Main_Data::game_player->GetSpriteDirection());
if (!IsAscendingOrDescending()) {
SetDirection(Main_Data::game_player->GetDirection());
SetSpriteDirection(Main_Data::game_player->GetSpriteDirection());
} else {
if (!IsMoving() && !IsJumping()) {
SetDirection(Left);
SetSpriteDirection(Left);
}
}
}

int Game_Vehicle::GetAltitude() const {
Expand Down Expand Up @@ -267,20 +279,22 @@ void Game_Vehicle::Update() {
}

if (type == Airship) {
if (IsAscending()) {
data()->remaining_ascent = data()->remaining_ascent - 8;
SetAnimFrame(AnimFrame::Frame_middle);
} else if (IsDescending()) {
SetAnimFrame(AnimFrame::Frame_middle);
data()->remaining_descent = data()->remaining_descent - 8;
if (!IsDescending()) {
if (CanLand()) {
Main_Data::game_player->UnboardingFinished();
SetFlying(false);
Main_Data::game_player->SetFlying(false);
} else {
// Can't land here, ascend again
data()->remaining_ascent = SCREEN_TILE_SIZE;
if (!IsMoving() && !IsJumping()) {
if (IsAscending()) {
data()->remaining_ascent = data()->remaining_ascent - 8;
SetAnimFrame(AnimFrame::Frame_middle);
} else if (IsDescending()) {
SetAnimFrame(AnimFrame::Frame_middle);
data()->remaining_descent = data()->remaining_descent - 8;
if (!IsDescending()) {
if (CanLand()) {
Main_Data::game_player->UnboardingFinished();
SetFlying(false);
Main_Data::game_player->SetFlying(false);
} else {
// Can't land here, ascend again
data()->remaining_ascent = SCREEN_TILE_SIZE;
}
}
}
}
Expand Down

0 comments on commit 9acfeda

Please sign in to comment.