Skip to content

Commit

Permalink
Support SavePanorama data
Browse files Browse the repository at this point in the history
* saves and loads scrolling panorama x and y position.
* Only supported by rm2k3e, but we enable for all modes.
  • Loading branch information
fmatthew5876 committed Nov 6, 2018
1 parent 4c589a4 commit 57f8643
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions src/game_map.cpp
Expand Up @@ -46,6 +46,7 @@
namespace {
RPG::SaveMapInfo& map_info = Main_Data::game_data.map_info;
RPG::SavePartyLocation& location = Main_Data::game_data.party_location;
RPG::SavePanorama& panorama = Main_Data::game_data.panorama;

std::string chipset_name;
std::string battleback_name;
Expand Down Expand Up @@ -134,6 +135,8 @@ void Game_Map::Quit() {
void Game_Map::Setup(int _id) {
SetupCommon(_id, false);
map_info.encounter_rate = GetMapInfo().encounter_steps;
panorama.pan_x = 0;
panorama.pan_y = 0;
ResetEncounterSteps();

Parallax::ClearChangedBG();
Expand Down Expand Up @@ -1423,11 +1426,11 @@ std::string Game_Map::Parallax::GetName() {
}

int Game_Map::Parallax::GetX() {
return parallax_x / TILE_SIZE;
return (parallax_x - panorama.pan_x / 2) / TILE_SIZE;
}

int Game_Map::Parallax::GetY() {
return parallax_y / TILE_SIZE;
return (parallax_y - panorama.pan_y / 2) / TILE_SIZE;
}

void Game_Map::Parallax::Initialize(int width, int height) {
Expand Down Expand Up @@ -1469,11 +1472,16 @@ void Game_Map::Parallax::Update() {
return 0;
};


if (params.scroll_horz && params.scroll_horz_auto) {
parallax_x += scroll_amt(params.scroll_horz_speed);
const auto w = parallax_width * TILE_SIZE * 2;
panorama.pan_x -= scroll_amt(params.scroll_horz_speed) * 2;
panorama.pan_x = (panorama.pan_x + w) % w;
}
if (params.scroll_vert && params.scroll_vert_auto) {
parallax_y += scroll_amt(params.scroll_vert_speed);
const auto h = parallax_height * TILE_SIZE * 2;
panorama.pan_y -= scroll_amt(params.scroll_vert_speed) * 2;
panorama.pan_y = (panorama.pan_y + h) % h;
}
}

Expand Down

0 comments on commit 57f8643

Please sign in to comment.