Skip to content

Coordinate systems

Two different coordinate systems are used within the game Retro Carnage. The first is the coordinate system of the game logic, in which, for example, the positions of enemies, obstacles and players are determined. This system is used throughout the game logic code.

The second coordinate system is used in the pixel library to calculate graphical output. If game content is to be displayed on the screen, a translation from one coordinate system to the other must therefore take place. User interfaces are realized directly in the coordinate system of the pixel library.

Coordinates in Retro Carnage

The coordinate system of the game logic has its point of origin [0 / 0] in the top left corner. The game area has a fixed size of 1,500 x 1,500. The point [1,500 / 1,500] is accordingly in the bottom right-hand corner.

Coordinate system of the game logic

When scrolling, the visible area always remains in the range from [0 / 0] to [1,500 / 1,500]. All elements of the current segment of the playing field are repositioned when scrolling - and can enter the visible area or be removed from it.

Scrolling

Coordinates in pixel

In the pixel library, which is used for graphical output, the origin point is in the bottom left corner.

Coordinate system of pixel

The translation from one coordinate system to the other takes place, for example, in the method drawSpriteToCanvas in the Renderer class.