About Camera


This will show you how SwinGame's camera can be used to create cool games.  


Level

Intermediate

Read these first

About Graphics

Details


The Camera

The camera provides an easy way to move around a game world. It is set to 0,0 by default, however the offset can be changed using SetCamera procedures. When the camera position changes it moves the window to another part of the game world, as you can see in the associated image.

When drawing to the game world the 'world coordinates' must be used because these describe where an object is in relation to 0,0.

However when receiving input from the user the 'screen coordinates' are used, in this system the coordinates are always 0,0 in the top left-hand corner, regardless of the camera position. You can translate between these coordinate systems using the ToScreen and ToWorld functions.



The World's x and y position will be different to the Screen's x and y position when the camera's position is not 0,0.


About Camera



There are a range of useful functions and procedures that can be used to manipulate the camera. A full reference can be found in the SwinGame API.


  • CameraX
  • CameraY
  • SetCameraX
  • SetCameraY
  • ToScreen
  • ToWorld