This page will go over some of the common questions new users have when starting out using raylib.
* How do I make a timer?
# How do I make a timer?
Raylib has no built in timer system. You are expected to keep track of time in your own code. You can do with with the GetTime and GetFrameTime functions. Below is an example of a simple timer struct and functions to use it.
```
@ -26,3 +26,46 @@ double GetElapsed(Timer timer)
return GetTime() - timer.StartTime;
}
```
# What do all the fields in Camera2d mean?
The Camera2d structure is used by `BeginMode2d/EndMode2d` to define a 2d transformation. This is very useful for games that want to draw a 2d world in a fixed coordinate system and have the ability to pan, zoom and rotate the view without the need to change drawing code.
## Fields
```
typedef struct Camera2D {
Vector2 offset; // Camera offset (displacement from target)
Vector2 target; // Camera target (rotation and zoom origin)
float rotation; // Camera rotation in degrees
float zoom; // Camera zoom (scaling), should be 1.0f by default
} Camera2D;
```
### Offset
The offset is used to shift the window origin away from the default of the upper left corner. it is a value defined in screen space. it is not affected by rotation or zoom. It is very common to set this to be half the window width/height in order to make the window origin be the center of the screen.
### Target
This is a point in world space that the camera will follow. It defines zoom and rotation pivot points. It is very common to set this value to the thing you want to track in your world, such as your player position.
### Rotation
This is the rotation angle that the view will be rotated by. It will rotate around the target point in world coordinates.
### Zoom
This is the scale factor applied to the view. A value of 1 will draw the world at it's original scale. A value of 2 will be a 2x zoom and draw everything twice as large on screen.
## Converting Coordinates
There will be times when you need to convert from screen coordinates into world coordinates, such as wanting to find out what the mouse's screen position is in the world.
This will convert a screen point into a world point for a camera. This will include zoom and scale. It is very common to use this to get the mouse position in world coordinates to do collisions or picking.
This function gets a screen point for a world point, using zoom and scale. It is useful for computing the location of HUD elements that should not be scaled or rotated with the world view, such as player names, health bars, or other labels.