Expand description
Engine core: Context, game loop, and window configuration.
§Why game-gem > macroquad (architecture)
| Feature | macroquad | game-gem |
|---|---|---|
| Entry point | #[macroquad::main] proc macro | Plain fn main() + Game::run() |
| State management | Global variables | Trait-based GameState |
| Error handling | Panics | Result types |
| Context passing | Global functions | Explicit &mut Context parameter |
| Modularity | All-or-nothing | Feature-gated modules |
| Multiple windows | No | Planned |
| Custom game loop | No | Fixed timestep, variable, or custom |
§Minimal example
use game_gem::prelude::*;
struct MyGame;
impl GameState for MyGame {
fn update(&mut self, ctx: &mut Context) {
if ctx.input.keyboard.is_pressed(KeyCode::Escape) {
ctx.quit();
}
}
fn render(&mut self, ctx: &mut Context) {
ctx.graphics.clear(Color::SKY_BLUE);
ctx.graphics.draw_circle(ctx, 400.0, 300.0, 50.0, Color::RED);
}
}
fn main() {
Game::new()
.window_title("My Game")
.window_size(800, 600)
.run(MyGame);
}Structs§
- Context
- The main context object passed to all game state methods.
- Game
- The game builder. Configure your game and run it.
- Graphics
Context - Graphics context that collects draw commands.
- Window
Config - Window configuration builder.
Enums§
- Draw
Command - Drawing operations that the game can issue each frame.
Traits§
- Game
State - The main game state trait. Implement this for your game.