Skip to content

Commit

Permalink
Do airship ascent/descent animation from player update routine
Browse files Browse the repository at this point in the history
Fixes #1675 Test case 13.2
  • Loading branch information
fmatthew5876 committed Mar 18, 2019
1 parent 7b4c9d0 commit 01722c5
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 22 deletions.
8 changes: 6 additions & 2 deletions src/game_player.cpp
Expand Up @@ -251,8 +251,12 @@ void Game_Player::Update() {
Game_Character::UpdateMovement();
Game_Character::UpdateAnimation(was_moving);

if (IsAboard() && GetVehicle()) {
GetVehicle()->SyncWithPlayer();
if (IsAboard()) {
auto* vehicle = GetVehicle();
if (vehicle) {
GetVehicle()->SyncWithPlayer();
vehicle->AnimateAscentDescent();
}
}

UpdateScroll(old_sprite_x, old_sprite_y);
Expand Down
41 changes: 21 additions & 20 deletions src/game_vehicle.cpp
Expand Up @@ -252,6 +252,27 @@ void Game_Vehicle::UpdateAnimationShip() {
}
}

void Game_Vehicle::AnimateAscentDescent() {
if (!IsStopping()) {
return;
}
if (IsAscending()) {
data()->remaining_ascent = data()->remaining_ascent - 8;
} else if (IsDescending()) {
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;
}
}
}
}

void Game_Vehicle::Update() {
if (IsProcessed()) {
return;
Expand All @@ -262,26 +283,6 @@ void Game_Vehicle::Update() {
Game_Character::UpdateMovement();
}

if (type == Airship) {
if (IsStopping()) {
if (IsAscending()) {
data()->remaining_ascent = data()->remaining_ascent - 8;
} else if (IsDescending()) {
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 (type == Airship) {
UpdateAnimationAirship();
} else {
Expand Down
1 change: 1 addition & 0 deletions src/game_vehicle.h
Expand Up @@ -66,6 +66,7 @@ class Game_Vehicle : public Game_Character {
bool IsInUse() const;
bool IsAboard() const;
void SyncWithPlayer();
void AnimateAscentDescent();
int GetScreenY(bool apply_shift = false) const override;
bool IsMovable();
bool CanLand() const;
Expand Down

0 comments on commit 01722c5

Please sign in to comment.