Snake in Odin

David MacDonald

Title Screen
Title Screen
Game Screen
Game Screen
draw :: proc(using game: ^Game, alloc := context.temp_allocator) {
draw_to_canvas(game)

rl.BeginDrawing()
defer rl.EndDrawing()

rl.ClearBackground(rl.RAYWHITE)
rl.DrawTextureRec(
canvas.texture,
{0, 0, f32(CANVAS_SIZE.x), f32(CANVAS_SIZE.y)},
{CANVAS_MARGIN, CANVAS_MARGIN},
rl.WHITE if !is_paused else rl.GRAY,
)

if is_paused {
plural := "" if snake.len - 1 == 1 else "s"
score := fmt.caprintf("You have %d point%s", snake.len - 1, plural, allocator = alloc)

draw_centered_text("PAUSED", 100, 60, rl.RED)
draw_centered_text(score, 160, 25, rl.GREEN)
draw_centered_text("Press P to unpause", 360, 25, rl.BLACK)
}
}

Like this project

Posted Oct 28, 2024

I created a snake clone using Raylib in a low-level language called Odin.

Improved Anvils - Minecraft Mod
Improved Anvils - Minecraft Mod
Simple Sudoku App
Simple Sudoku App

Join 50k+ companies and 1M+ independents

Contra Logo

© 2025 Contra.Work Inc