MCPcopy Create free account
hub / github.com/OpenXcom/OpenXcom / scrollXY

Method scrollXY

src/Battlescape/Camera.cpp:345–367  ·  view source on GitHub ↗

* Handles scrolling with given deviation. * @param x X deviation. * @param y Y deviation. * @param redraw Redraw map or not. */

Source from the content-addressed store, hash-verified

343 * @param redraw Redraw map or not.
344 */
345void Camera::scrollXY(int x, int y, bool redraw)
346{
347 _mapOffset.x += x;
348 _mapOffset.y += y;
349
350 do
351 {
352 convertScreenToMap((_screenWidth / 2), (_visibleMapHeight / 2), &_center.x, &_center.y);
353
354 // Handling map bounds...
355 // Ok, this is a prototype, it should be optimized.
356 // Actually this should be calculated instead of slow-approximation.
357 if (_center.x < 0) { _mapOffset.x -= 1; _mapOffset.y -= 1; continue; }
358 if (_center.x > _mapsize_x -1) { _mapOffset.x += 1; _mapOffset.y += 1; continue; }
359 if (_center.y < 0) { _mapOffset.x += 1; _mapOffset.y -= 1; continue; }
360 if (_center.y > _mapsize_y -1) { _mapOffset.x -= 1; _mapOffset.y += 1; continue; }
361 break;
362 }
363 while (true);
364
365 _map->refreshSelectorPosition();
366 if (redraw) _map->invalidate();
367}
368
369
370/**

Callers 1

mapOverMethod · 0.80

Calls 2

invalidateMethod · 0.80

Tested by

no test coverage detected