How wilsonsilva/raylib-tic-tac-toe works
Project type and purpose
• This is a small, single-player tic-tac-toe game written in C, using the raylib graphics library.
• It targets two platforms: native desktop (Windows/Linux/Mac) and web via Emscripten (WASM + HTML shell).
File structure
• Top-level:
• CMakeLists.txt & Justfile – build orchestration (native and web)
• resources/textures – static assets (images, sprites)
• src/ – C source code and HTML shells for web
• src modules:
• main.c – application entry point, game loop
• animations.c/.h – animation routines
• reasings.h – easing functions for animations
• shell.html & minshell.html – HTML wrapper for the WASM build
Key insights from README
• Dependencies: raylib, CMake, optionally Just, Emscripten for web
• Build targets: build-debug, build-release (desktop), build-web (WASM + HTML)
• Runtime: loads textures at startup, runs a continuous game loop (input → update → render)
• Build System
– Justfile / CMake → native toolchain or Emscripten
• Platform Layer
– Native OS (GLFW/window management) OR Browser (HTML shell + JS glue + WASM)
• raylib Library
– Graphics, input, audio, timing
• Game Core
– main.c (game loop)
– Input Handler
– Game Logic (board state, win detection)
– Animation Module (animations.c + reasings.h)
• Resource Manager
– Texture loader (resources/textures)
• Output
– Native executable (.exe/.app) OR HTML + WASM module
b. Relationships and data flow
• Build System → compiles → Game Core + raylib → Produces native EXE or WASM
• At runtime: User input → Platform Layer → Game Core → Resource Manager/raylib → Render surface → Display to user
• Game Core calls Animation Module for smooth UI transitions
• Resource Manager loads textures at init and provides to raylib
c. Architectural patterns & design principles
• Modular separation:
– Clear division of concerns (input, logic, rendering, animations)
• Single game loop architecture (update → render cycle)
• Cross-platform abstraction via CMake/Emscripten
d. Technology & libraries
• raylib (C graphics/input)
• CMake + Just (build definitions)
• Emscripten (WASM + HTML shell)