Skip to content

Instantly share code, notes, and snippets.

@doccaico
Created December 4, 2025 00:44
Show Gist options
  • Select an option

  • Save doccaico/239bcc545d53d4fed58ad5976479fb0a to your computer and use it in GitHub Desktop.

Select an option

Save doccaico/239bcc545d53d4fed58ad5976479fb0a to your computer and use it in GitHub Desktop.
paint circles in Odin and Raylib
package main
import "core:container/queue"
// import "core:fmt"
import rl "vendor:raylib"
SCREEN_WIDTH :: 800
SCREEN_HEIGHT :: 450
FPS :: 60
QUEUE_LENGTH :: 70
RADIUS_MIN :: 20
RADIUS_MAX :: 40
Circle :: struct {
pos: rl.Vector2,
radius: f32,
color: rl.Color,
}
main :: proc() {
rl.InitWindow(SCREEN_WIDTH, SCREEN_HEIGHT, "paint circles ")
defer rl.CloseWindow()
rl.SetTargetFPS(FPS)
q: queue.Queue(Circle)
queue.init(&q, capacity = QUEUE_LENGTH)
defer queue.destroy(&q)
for !rl.WindowShouldClose() {
if rl.IsMouseButtonDown(rl.MouseButton.LEFT) {
pos := rl.GetMousePosition()
radius := rl.GetRandomValue(RADIUS_MIN, RADIUS_MAX)
color := rl.Color{
u8(rl.GetRandomValue(0, 255)),
u8(rl.GetRandomValue(0, 255)),
u8(rl.GetRandomValue(0, 255)),
255,
}
queue.push_back(&q, Circle{pos, f32(radius), color})
}
if queue.len(q) == QUEUE_LENGTH {
_ = queue.pop_front(&q)
}
rl.BeginDrawing()
rl.ClearBackground(rl.RAYWHITE)
for i := 0; i < queue.len(q); i += 1 {
circle := queue.get(&q, i)
rl.DrawCircleV(circle.pos, circle.radius, circle.color)
}
rl.EndDrawing()
}
}
// rl.DrawText("Congrats! You created your first window!", 190, 200, 20, rl.LIGHTGRAY)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment