game_gem/lib.rs
1//! # game-gem
2//!
3//! A blazing-fast, ergonomic 2D game library for Rust — **no macros, no magic, just gems.**
4//!
5//! ## Why game-gem?
6//!
7//! `game-gem` is designed as a modern, modular alternative to `macroquad` with:
8//!
9//! - **No proc macros** — Plain `trait GameState` + `Game::run()` instead of `#[macroquad::main]`
10//! - **Explicit context** — All state passed via `&mut Context`, no global variables
11//! - **Feature-gated modules** — Only compile what you use (audio, UI, particles, etc.)
12//! - **Built-in systems** that macroquad lacks entirely:
13//! - Scene management with transitions
14//! - Particle system with emitters
15//! - Tweening with 30+ easing functions
16//! - Sprite animation with state machine
17//! - Collision detection (AABB, circle, ray casting, spatial hash)
18//! - Immediate-mode UI toolkit
19//! - Spatial audio with 2D positioning
20//! - Camera system with shake, follow, and split-screen
21//! - Asset management with hot-reload support
22//! - **Zero-cost abstractions** — Feature flags mean unused modules don't exist in your binary
23//! - **Proper error handling** — `Result` types instead of panics
24//!
25//! ## Quick Start
26//!
27//! ```no_run
28//! use game_gem::prelude::*;
29//!
30//! struct MyGame;
31//!
32//! impl GameState for MyGame {
33//! fn update(&mut self, ctx: &mut Context) {
34//! if ctx.input.keyboard.is_pressed(KeyCode::Escape) {
35//! ctx.quit();
36//! }
37//! }
38//!
39//! fn render(&mut self, ctx: &mut Context) {
40//! ctx.graphics.clear(Color::SKY_BLUE);
41//! ctx.graphics.draw_rect(100.0, 100.0, 200.0, 150.0, Color::GOLD);
42//! ctx.graphics.draw_text("Hello, game-gem!", 50.0, 50.0, 32.0, Color::WHITE);
43//! }
44//! }
45//!
46//! fn main() {
47//! Game::new()
48//! .window_title("Hello game-gem!")
49//! .window_size(800, 600)
50//! .run(MyGame);
51//! }
52//! ```
53//!
54//! ## Module Overview
55//!
56//! | Module | Feature flag | Description |
57//! |--------|-------------|-------------|
58//! | [`math`] | (always) | Vec2, Rect, Transform, Angle, Lerp |
59//! | [`color`] | (always) | Color with HSL/HSV, hex parsing, named constants |
60//! | [`time`] | (always) | Delta time, FPS tracking, Timer, fixed timestep |
61//! | [`input`] | (always) | Keyboard, mouse, gamepad, remappable actions |
62//! | [`camera`] | (always) | Multi-camera, follow, shake, split-screen |
63//! | [`engine`] | (always) | Game loop, Context, GameState trait, WindowConfig |
64//! | [`collision`] | `collision` | AABB, circle, ray, spatial hash |
65//! | [`particles`] | `particles` | Emitters, shapes, easing, pooling |
66//! | [`tween`] | `tween` | 30+ easing functions, TweenManager |
67//! | [`animation`] | `animation` | Sprite sheet animation, events |
68//! | [`scene`] | (always) | Scene stack, transitions |
69//! | [`ui`] | `ui` | Buttons, sliders, text input, layouts |
70//! | [`assets`] | (always) | Asset handles, ImageAsset, SpriteSheet |
71//! | [`audio`] | `audio` | Spatial audio, music/SFX channels, fade |
72//!
73//! ## Feature Flags
74//!
75//! ```toml
76//! [dependencies]
77//! game-gem = { version = "0.1", features = ["audio", "ui", "particles", "animation", "tween", "collision"] }
78//! ```
79//!
80//! All features are enabled by default. Disable what you don't need:
81//!
82//! ```toml
83//! game-gem = { version = "0.1", default-features = false, features = ["collision"] }
84//! ```
85
86// ─────────────────────────────────────────────
87// Core modules (always compiled)
88// ─────────────────────────────────────────────
89pub mod math;
90pub mod color;
91pub mod time;
92pub mod input;
93pub mod camera;
94pub mod engine;
95pub mod scene;
96pub mod assets;
97
98// ─────────────────────────────────────────────
99// Feature-gated modules
100// ─────────────────────────────────────────────
101#[cfg(feature = "collision")]
102pub mod collision;
103
104#[cfg(feature = "particles")]
105pub mod particles;
106
107#[cfg(feature = "tween")]
108pub mod tween;
109
110#[cfg(feature = "animation")]
111pub mod animation;
112
113#[cfg(feature = "ui")]
114pub mod ui;
115
116#[cfg(feature = "audio")]
117pub mod audio;
118
119// ─────────────────────────────────────────────
120// Prelude
121// ─────────────────────────────────────────────
122pub mod prelude;