Add syntax highlighting to code examples

master
Peter0x44 3 years ago
parent
commit
ac6eeba80f
1 changed files with 4 additions and 4 deletions
  1. +4
    -4
      Frequently-asked-Questions--Common-Questions.md

+ 4
- 4
Frequently-asked-Questions--Common-Questions.md

@ -3,7 +3,7 @@ This page will go over some of the common questions new users have when starting
# 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. 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.
```
```c
typedef struct typedef struct
{ {
double StartTime; double StartTime;
@ -32,7 +32,7 @@ double GetElapsed(Timer timer)
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. 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 ## Fields
```
```c
typedef struct Camera2D { typedef struct Camera2D {
Vector2 offset; // Camera offset (displacement from target) Vector2 offset; // Camera offset (displacement from target)
Vector2 target; // Camera target (rotation and zoom origin) Vector2 target; // Camera target (rotation and zoom origin)
@ -73,13 +73,13 @@ This function gets a screen point for a world point, using zoom and scale. It is
Raylib does not offer any text formatting functions, so you need to compute the starting point for all text that you draw. The starting point for text is always the upper left corner. Raylib does not offer any text formatting functions, so you need to compute the starting point for all text that you draw. The starting point for text is always the upper left corner.
You can compute the center of the screen by dividing the screen width and hieght in half. You can compute the center of the screen by dividing the screen width and hieght in half.
```
```c
int screenCenterX = GetScreenWidth() / 2; int screenCenterX = GetScreenWidth() / 2;
int screenCenterY = GetScreenHeight() / 2; int screenCenterY = GetScreenHeight() / 2;
``` ```
Next you need to compute how large the text is, and offset the center by half the text size. Next you need to compute how large the text is, and offset the center by half the text size.
```
```c
const char* text = "Congrats! You created your first window!"; const char* text = "Congrats! You created your first window!";
int fontSize = 20; int fontSize = 20;

Loading…
Cancel
Save