| 94 | } |
| 95 | |
| 96 | static void testAnimPan(Game_Player::PanDirection dir_x, Game_Player::PanDirection dir_y, int speed) { |
| 97 | static constexpr auto map_id = MockMap::ePass40x30; |
| 98 | |
| 99 | const MockGame mg(map_id); |
| 100 | auto& ch = *mg.GetPlayer(); |
| 101 | |
| 102 | ch.SetMapId(static_cast<int>(map_id)); |
| 103 | ch.MoveTo(static_cast<int>(map_id), 20, 15); |
| 104 | |
| 105 | ch.StartPan(dir_x, 1, speed); |
| 106 | ch.StartPan(dir_y, 2, speed); |
| 107 | |
| 108 | auto wait = 2 * SCREEN_TILE_SIZE / (2 << speed); |
| 109 | |
| 110 | int step_x = 2 << speed; |
| 111 | int step_y = 2 << speed; |
| 112 | int dx = 0; |
| 113 | int dy = 0; |
| 114 | int fx = 1 * SCREEN_TILE_SIZE; |
| 115 | int fy = 2 * SCREEN_TILE_SIZE; |
| 116 | |
| 117 | if (dir_x == Game_Player::PanRight) { |
| 118 | fx = -1 * SCREEN_TILE_SIZE; |
| 119 | } |
| 120 | if (dir_y == Game_Player::PanDown) { |
| 121 | fy = -2 * SCREEN_TILE_SIZE; |
| 122 | } |
| 123 | |
| 124 | CAPTURE(speed); |
| 125 | CAPTURE(dir_x); |
| 126 | CAPTURE(dir_y); |
| 127 | CAPTURE(step_x); |
| 128 | CAPTURE(step_y); |
| 129 | CAPTURE(wait); |
| 130 | CAPTURE(fx); |
| 131 | CAPTURE(fy); |
| 132 | |
| 133 | testPanAbs(ch, true, false, 0, 0, fx, fy, wait); |
| 134 | |
| 135 | for (int i = 1; i < wait; ++i) { |
| 136 | ForceUpdate(ch); |
| 137 | if (dir_x == Game_Player::PanRight) { |
| 138 | dx = std::max(dx - step_x, fx); |
| 139 | } else { |
| 140 | dx = std::min(dx + step_x, fx); |
| 141 | } |
| 142 | if (dir_y == Game_Player::PanDown) { |
| 143 | dy = std::max(dy - step_y, fy); |
| 144 | } else { |
| 145 | dy = std::min(dy + step_y, fy); |
| 146 | } |
| 147 | testPanAbs(ch, true, false, dx, dy, fx, fy, wait - i); |
| 148 | } |
| 149 | |
| 150 | ForceUpdate(ch); |
| 151 | testPanAbs(ch, false, false, fx, fy, fx, fy, 0); |
| 152 | |
| 153 | ch.ResetPan(speed); |
no test coverage detected