コード例 #1
0
ファイル: game_map.cpp プロジェクト: Ghabry/easyrpg-player
void Game_Map::UpdatePan() {
	if (!IsPanActive())
		return;

	const int step = location.pan_speed;
	const int pan_remain_x = location.pan_current_x - location.pan_finish_x;
	const int pan_remain_y = location.pan_current_y - location.pan_finish_y;

	int dx = std::min(step, std::abs(pan_remain_x));
	dx = pan_remain_x >= 0 ? dx : -dx;
	int dy = std::min(step, std::abs(pan_remain_y));
	dy = pan_remain_y >= 0 ? dy : -dy;

	int screen_x = Game_Map::GetPositionX();
	int screen_y = Game_Map::GetPositionY();

	Game_Map::AddScreenX(screen_x, dx);
	Game_Map::AddScreenY(screen_y, dy);

	// If we hit the edge of the map before pan finishes, the
	// pan converts from waiting to non-waiting.
	if (dx == 0 && dy == 0) {
		pan_wait = false;
		return;
	}

	Game_Map::ScrollRight(dx);
	Game_Map::ScrollDown(dy);

	location.pan_current_x -= dx;
	location.pan_current_y -= dy;
}
コード例 #2
0
ファイル: game_map.cpp プロジェクト: cheerjo/Player
void Game_Map::UpdatePan() {
	if (!IsPanActive())
		return;

	int step = 2 << (pan_speed - 1);
	int dx = location.pan_finish_x - location.pan_current_x;
	int dy = location.pan_finish_y - location.pan_current_y;

	if (dx > 0)
		location.pan_current_x += std::min(step, dx);
	else if (dx < 0)
		location.pan_current_x -= std::min(step, -dx);

	if (dy > 0)
		location.pan_current_y += std::min(step, dy);
	else if (dy < 0)
		location.pan_current_y -= std::min(step, -dy);
}
コード例 #3
0
ファイル: game_map.cpp プロジェクト: cheerjo/Player
bool Game_Map::IsPanWaiting() {
	return IsPanActive() && pan_wait;
}