Raylib Overview
When you draw or otherwise locate objects, coordinates are measured in pixels and start at the top left of your window. So, if you think of horizontal as the x-direction and vertical as the y-direction, then the origin [0, 0] is at the top left, with y pointing down.
Raylib uses double-buffering, and your program runs in a loop that (after initializing things) goes like:
check if looping should continue (if not, exits loop)
update the game/world
begin-drawing (starts you off with a new buffer)
clear screen
draw the game/world (on the back buffer)
end-drawing (swaps buffers)
To keep organized, separate out your functions into init_game
, update_game
, and draw_game
.
So that your game/sim/computation loop doesn’t speed out of control, call rl.set_target_fps(60)
in your init_game
.