Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Crate coffee

Source
Expand description

Coffee is an opinionated 2D game engine focused on simplicity, explicitness, and type-safety.

§Features

Check out the repository and the examples for more details!

§Usage

To get started, implement the Game trait. Then, call Game::run with some WindowSettings to run your game.

Here is a minimal example that will open a window:

use coffee::graphics::{Color, Frame, Window, WindowSettings};
use coffee::load::Task;
use coffee::{Game, Result, Timer};

fn main() -> Result<()> {
    MyGame::run(WindowSettings {
        title: String::from("A caffeinated game"),
        size: (1280, 1024),
        resizable: true,
        fullscreen: false,
        maximized: false,
    })
}

struct MyGame {
    // Your game state and assets go here...
}

impl Game for MyGame {
    type Input = (); // No input data
    type LoadingScreen = (); // No loading screen

    fn load(_window: &Window) -> Task<MyGame> {
        // Load your game assets here. Check out the `load` module!
        Task::succeed(|| MyGame { /* ... */ })
    }

    fn draw(&mut self, frame: &mut Frame, _timer: &Timer) {
        // Clear the current frame
        frame.clear(Color::BLACK);

        // Draw your game here. Check out the `graphics` module!
    }
}

Modules§

graphics
Draw your game with an explicit 2D graphics API.
input
Allow players to interact with your game.
load
Load your game assets with type-safety and build loading screens with consistent progress tracking.
ui
Build a responsive graphical user interface for your game.

Structs§

Debug
A bunch of performance information about your game. It can be drawn!
Timer
The timer of your game state.

Enums§

Error
An error in the engine.

Traits§

Game
The entrypoint of the engine. It describes your game logic.

Type Aliases§

Result
A convenient result with a locked Error type.