Last active
March 8, 2025 15:53
-
-
Save karl-zylinski/ec4cac8d378d1cdbe7aa74feec1cace4 to your computer and use it in GitHub Desktop.
For getting started with Odin + Raylib
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
This is a minimal Odin + Raylib example. | |
Put this file in an empty folder, navigate to that folder using a teriminal | |
and then run this command: | |
odin run . | |
To see all the things available in Raylib, open `raylib.odin` and look around. | |
You'll find it here: | |
<odin_install_directory>/vendor/raylib/raylib.odin | |
*/ | |
package game | |
import rl "vendor:raylib" | |
main :: proc() { | |
rl.SetConfigFlags({ .VSYNC_HINT }) | |
rl.InitWindow(1280, 720, "Odin + Raylib game") | |
pos_x := f32(200) | |
for !rl.WindowShouldClose() { | |
if rl.IsKeyDown(.LEFT) { | |
pos_x -= 400 * rl.GetFrameTime() | |
} | |
if rl.IsKeyDown(.RIGHT) { | |
pos_x += 400 * rl.GetFrameTime() | |
} | |
rl.BeginDrawing() | |
rl.ClearBackground({ 55, 130, 209, 255 }) | |
rl.DrawRectangleRec({ pos_x, 20, 40, 40 }, rl.WHITE) | |
rl.EndDrawing() | |
} | |
rl.CloseWindow() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment