int Game_Map::RoundX(int x) { if ( LoopHorizontal() ) { return (x + GetWidth()) % GetWidth(); } else { return x; } }
int Game_Map::RoundX(int x) { if (LoopHorizontal()) { return Utils::PositiveModulo(x, GetWidth()); } else { return x; } }
void Game_Map::AddScreenX(int& screen_x, int& inc) { int map_width = GetWidth() * SCREEN_TILE_SIZE; if (LoopHorizontal()) { screen_x = Utils::PositiveModulo(screen_x + inc, map_width); } else { ClampingAdd(0, map_width - SCREEN_WIDTH, screen_x, inc); } }
void Game_Map::SetPositionX(int x) { const int map_width = GetWidth() * SCREEN_TILE_SIZE; if (LoopHorizontal()) { x = Utils::PositiveModulo(x, map_width); } else { x = std::max(0, std::min(map_width - SCREEN_WIDTH, x)); } map_info.position_x = x; Parallax::ResetPositionX(); }
void Game_Map::Parallax::ResetPositionX() { Params params = GetParallaxParams(); panorama.pan_x = 0; if (params.name.empty()) { return; } if (params.scroll_horz || LoopHorizontal()) { panorama.pan_x = map_info.position_x; } else if (GetWidth() > 20 && parallax_width > SCREEN_TARGET_WIDTH) { panorama.pan_x = std::min(map_info.position_x * (parallax_width - SCREEN_TARGET_WIDTH) * 2 / ((GetWidth() - 20) * TILE_SIZE) , map_info.position_x * 2); } }