[−][src]Crate coffee
Coffee is an opinionated 2D game engine focused on simplicity, explicitness, and type-safety.
Features
- Declarative, type-safe asset loading
- Loading screens with progress tracking
- Built-in debug view with performance metrics
- Fixed timestep
- Explicit, easy to use, hardware-accelerated 2D graphics API
- Multiplatform support leveraging OpenGL, Vulkan, Metal, D3D11, and D3D12
- Texture array support
- Explicit and efficient batched draws
- Off-screen rendering
- TrueType font rendering
Check out the repository for more details!
Usage
To get started, simply 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::{Game, Result, Timer}; use coffee::graphics::{Color, Window, WindowSettings}; fn main() -> Result<()> { MyGame::run(WindowSettings { title: String::from("A caffeinated game"), size: (1280, 1024), resizable: true, }) } struct MyGame { // Your game state goes here... } impl Game for MyGame { type View = (); // No view data. type Input = (); // No input data. const TICKS_PER_SECOND: u16 = 60; // Update rate fn new(_window: &mut Window) -> Result<(MyGame, Self::View, Self::Input)> { // Load your game assets here. Check out the `load` module! Ok((MyGame { /* ... */ }, (), ())) } fn update(&mut self, _view: &Self::View, _window: &Window) { // Update your game here } fn draw(&self, _view: &mut Self::View, window: &mut Window, _timer: &Timer) { // Clear the current frame let mut frame = window.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. |
Structs
Debug | A bunch of performance information about your game. It can be drawn! |
Timer | The timer of your game. |
Enums
Error | An error in the engine. |
Traits
Game | The entrypoint of the engine. It describes your game logic. |
Type Definitions
Result | A convenient result with a locked |