o
odin.langpkg.dev
packages / library / SpaceSquares

SpaceSquares

ddbdb4flibrary

No description provided.

No license · updated 4 weeks ago

Space Squares

A fast-paced reflex game built with Odin and Raylib. Pilot a neon square through a cyberpunk grid and link up with glowing targets as quickly as you can.

Gameplay

You control a cyan neon square on a dark, scrolling grid. A pulsing target appears somewhere on screen — reach it before the timer runs your patience dry. Each successful collision counts as a link, resets the clock, and spawns a new target somewhere else in the arena.

The goal is simple: chain links together and beat your personal record.

Stat Description
Elapsed Time since the current target spawned
Record Your fastest link time
Links Total successful collisions

New targets always spawn at least 220 pixels from the player, so you won't get cheap instant re-hits that skew your record.

Controls

Input Action
Move the player square

Features

  • Cyberpunk visual style — deep navy background, electric blue neon palette, CRT scanlines, and sci-fi HUD panels
  • Neon glow rendering — additive blend layers simulate bloom without custom shaders
  • Animated perspective grid — scrolling floor grid with depth-based line weight
  • Motion trail — fading afterimage follows the player
  • Particle bursts — explosion of neon sparks on each link
  • Screen flash — brief cyan pulse on collision for hit feedback

Tech Stack

This project is a single-file game written in Odin using Raylib via Odin's official vendor:raylib bindings.

Why Odin?

Odin is a general-purpose language focused on high performance and clean syntax. For a small game like this, it offers:

  • Structs and procedures for clear game-state modeling (Player, Target, Game_State)
  • Compile-time constants for tuning values (MIN_SPAWN_DISTANCE, color palette)
  • No runtime overhead — the game loop runs natively with minimal abstraction
  • Built-in math via core:math for movement, pulsing animations, and spawn distance checks

How Raylib Is Used

Raylib handles everything graphical and interactive. The game uses it for:

Category Raylib APIs
Window & loop InitWindow, SetTargetFPS, WindowShouldClose, GetFrameTime
Input IsKeyDown for arrow-key movement
Drawing DrawRectangle, DrawCircleV, DrawLineEx, DrawRectangleGradientV, DrawRectangleLinesEx
Effects BeginBlendMode(.ADDITIVE) for neon glow and particle bloom
Collision CheckCollisionRecs between player and target rectangles
Text DrawText, TextFormat, MeasureText for the HUD
Randomness GetRandomValue for target placement and particle spread

The render loop follows the standard Raylib pattern:

Update game state  →  BeginDrawing  →  Draw everything  →  EndDrawing

All visual effects are procedural — no external assets, textures, or fonts are loaded. The neon look is built by layering semi-transparent shapes with additive blending.

Requirements

  • Odin compiler (dev-2026-06 or later)
  • Raylib (bundled with Odin's vendor:raylib — no separate install needed)

Build & Run

Clone the repo and compile from the project root:

odin build . -out:space_squares
./space_squares

On Windows:

odin build . -out:space_squares.exe
space_squares.exe

Project Structure

.
├── main.odin    # Entire game — logic, rendering, and entry point
└── README.md

Everything lives in main.odin. The file is organized into:

  1. Constants & types — palette, particle limits, game structs
  2. Rendering helpers — neon shapes, background grid, HUD, scanlines
  3. Game systems — particles, trail, target spawning
  4. main — initialization, input, collision, and the frame loop