Gama is a lightweight, cross-platform game engine written in C, designed with simplicity and education in mind. It aims to provide a convenient and powerful way for students and beginners to create 2D games(and some real-time graphical applications) while learning the fundamentals of C programming. The engine prioritizes a minimal, clean C API, control over the game loop, and a stack-first memory philosophy.
Gama is built on a few core principles to make game development in C more approachable and fun:
malloc and free.main loop.malloc implementation, ideal for controlled memory environments like WASM..obj and .gltf 3D models.gmw_button: An interactive button.gmw_switch: A toggle switch.gmw_scale: A slider for selecting a value in a range.gmw_joystick: A virtual joystick for on-screen controls.gmw_frame: A panel for grouping UI elements.PATH configuration needed.tcc and zig from your system's package manager, ensuring seamless integration.gama dev for Rapid Development: Use gama dev to instantly run your project with the fast TCC compiler. This command also features hot-reloading for rapid iteration.gama build for Optimization: When ready to create a release build, gama build uses the more powerful and optimizing Zig CC compiler.gama tcc, gama zig, and gama zcc as direct replacements for the real commands.spring, ease-in, ease-out) for smooth animations.Gama's cross-platform power comes from its flexible backend architecture.
libvgama: The native heart of the engine. Written in V, libvgama runs a sokol-based game loop, providing a fast and efficient rendering backend via gg.gama.js: The web backend. This TypeScript runner uses a Web Worker and SharedArrayBuffer to run your C code (compiled to WASM) off the main thread for maximum performance in the browser.Getting started with Gama is designed to be as simple as possible.
Download and Install:
gama-*-windows-setup.exe from the releases page. The installer handles everything for you..deb or .pkg.tar.zst package and install it with your system's package manager. Make sure you also have tcc and zig installed (sudo apt install tcc zig or sudo pacman -S tcc zig).Create a New Project: Open a terminal and run:
gama new my_first_game
Run in Development Mode: Navigate into your new project and start the development server:
cd my_first_game
gama dev
Your game window will appear, and the code will automatically re-compile and re-run whenever you save a change.
Build for the Web: To compile your project for a web browser, run:
gama build web
This will create a build/web directory containing all the files needed to run your game on a local web server.
Here is a simple example of a "Hello, World" application in Gama to demonstrate the basic structure.
#include <gama.h>
int main() {
// Initialize the engine and create a 600x400 window
gm_init(600, 400, "Hello Gama!");
// Set a background color
gm_background(GM_DARKSLATEGRAY);
// Main game loop
while (gm_yield()) {
// gm_yield() handles events, clears the screen, and returns
// true as long as the window is open.
// Draw a red rectangle in the center of the screen
gm_draw_rectangle(0, 0, 0.5, 0.3, GM_RED);
// Draw some text
gm_draw_text(0, 0, "Hello, World!", "default-ui", 0.1, GM_WHITE);
}
// The engine will automatically handle cleanup on exit.
return 0;
}
mng build script is written in V. You will need to install the V compiler from vlang.io.vlibvgama (e.g., clang or gcc).bun: For building gama.js.unzip: The mng script uses unzip to set up the Zig toolchain for packaging.makensis (Optional): For building the Windows installer.nfpm (Optional): For creating .deb packages.The project uses two primary scripts for development and packaging, both located at the project root.
./mng: This is a task runner written in V, used for most common development operations. It allows you to build individual components of the Gama ecosystem.
./mng build: Compiles the gama CLI tool for all target platforms../mng runner native: Builds the libvgama native library../mng runner web: Builds the gama.js web runner../mng get-zig: Downloads and sets up the Zig compiler needed for packaging../mng package: Creates the final distributable packages (.deb, .tar.zst, .exe installer)../all: This is a simple shell script that runs the entire build and packaging pipeline from start to finish. It's the easiest way to ensure all components are up-to-date and generate a full release.
lib/gama/: Contains all the core C header files for the engine's modules (3D, physics, widgets, etc.).gama/: Vlang source code for the main gama CLI tool and build logic.gama.js/: TypeScript source for the WebAssembly frontend and JS/C interop.mng: The main V script used for building, packaging, and managing the project.all: The master shell script to build and package everything.runners/: Contains the platform-specific code for running Gama applications (e.g., on web or native).site/: SvelteKit source code for the official website and documentation portal.test/: Contains example projects and test cases for the engine.Contributions are welcome! Please feel free to submit a pull request or open an issue.
To contribute to the website or documentation:
site/ directory../mng docs command.This project is licensed under the MIT License - see the LICENSE file for details.