• Stars
    star
    1,072
  • Rank 43,150 (Top 0.9 %)
  • Language
    Rust
  • License
    MIT License
  • Created over 5 years ago
  • Updated 10 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

An opinionated 2D game engine for Rust

Coffee

Integration status Documentation Crates.io License Gitter chat

An opinionated 2D game engine for Rust focused on simplicity, explicitness, and type-safety.

Coffee is in a very early stage of development. Many basic features are still missing, some dependencies are experimental, and there are probably many bugs. Feel free to contribute!

Features

And more! Check out the examples to see them in action.

Usage

Add coffee as a dependency in your Cargo.toml and enable a graphics backend feature (opengl, vulkan, metal, dx11, or dx12):

coffee = { version = "0.4", features = ["opengl"] }

Rust is quite slow in debug mode. If you experience performance issues when drawing hundreds of sprites, enable compiler optimizations in your Cargo.toml. I recommend level 2 optimizations in order to stay closer to --release performance:

[profile.dev]
opt-level = 2

Coffee moves fast and the master branch can contain breaking changes! If you want to learn about a specific release, check out the release list.

Overview

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!
    }
}

Browse the documentation and the examples to learn more!

Implementation details

Coffee builds upon

  • winit for windowing and mouse/keyboard events.
  • gfx pre-ll for OpenGL support, based heavily on the ggez codebase.
  • wgpu for experimental Vulkan, Metal, D3D11 and D3D12 support.
  • stretch for responsive GUI layouting based on Flexbox.
  • glyph_brush for TrueType font rendering.
  • gilrs for gamepad support.
  • nalgebra for the Point, Vector, and Transformation types.
  • image for image loading and texture array building.

Contributing / Feedback

I am quite new to Rust, systems programming, and computer graphics. I am learning along the way as I build the engine for a game I am currently developing. I am always glad to to learn from anyone.

If you want to contribute, you are more than welcome to be a part of the project! Check out the current issues if you want to find something to work on. Try to share you thoughts first! Feel free to open a new issue if you want to discuss new ideas.

Any kind of feedback is welcome! You can open an issue or, if you want to talk, you can find me (and a bunch of awesome folks) over the #games-and-graphics channel in the Rust Community Discord. I go by @lone_scientist there.

Credits / Thank you

  • ggez, an awesome, easy-to-use, good game engine that introduced me to Rust. Its graphics implementation served me as a guide to implement OpenGL support for Coffee.
  • Kenney, creators of amazing free game assets with no strings attached. The built-in GUI renderer in Coffee uses a modified version of their UI sprites.

More Repositories

1

wgpu_glyph

A fast text renderer for wgpu (https://github.com/gfx-rs/wgpu)
Rust
449
star
2

composable-form

Build type-safe composable forms in Elm
Elm
200
star
3

zelda

A Zelda clone in C++
C
154
star
4

setup-rust-action

Set up a specific Rust toolchain in your GitHub workflows
Shell
103
star
5

html-parser

Parse HTML 5 in Elm
Elm
61
star
6

icebreaker

A local AI chat app powered by 🦀 Rust, 🧊 iced, 🤗 Hugging Face, and 🦙 llama.cpp
Rust
39
star
7

window_clipboard

A library to obtain clipboard access from a `raw-window-handle`.
Rust
21
star
8

glow_glyph

A fast text renderer for glow (https://github.com/grovesNL/glow)
Rust
13
star
9

elm-slug

Type-safe slugs for Elm
Elm
10
star
10

download-release-action

Download the assets of a GitHub release
TypeScript
5
star
11

reticular

Lightweight Python module for creating powerful command-line tools
Python
4
star
12

piet-window

A simple crate to obtain a Piet renderer from a raw-window-handle
Rust
3
star
13

SwiftDecodePipeline

A library for building JSON decoders using the pipeline operator. Inspired by https://github.com/NoRedInk/elm-decode-pipeline.
Swift
3
star
14

idi

Interaction and Design of Interfaces - FIB - Fall 2013
Makefile
3
star
15

fast

A command-line tool to test the optimizations performed to a program.
Python
3
star
16

jtest

Tool for automatic testing and creating problems from Jutge.org
Ruby
2
star
17

advent_of_code

My solutions to Advent of Code
Haskell
2
star
18

mmpg

My final project for the computer science degree at FIB
TeX
2
star
19

rom-filesystem

Filesystem adapter for ROM
Ruby
1
star
20

words

words is a simple program that estimates the number of different words that a file contains.
TeX
1
star
21

alg

Algorithmics - FIB - Fall 2013
C++
1
star
22

eda

Estructuras de Datos y Algoritmos - FIB - UPC - 2012
C++
1
star
23

haskell-format

A highly opinionated Haskell formatter
Haskell
1
star
24

ies

No more sequence diagrams!
Java
1
star