Snake in Odin

David MacDonald

Game Developer
Software Engineer
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)
}
}

Partner With David
View Services

More Projects by David