- Notifications
You must be signed in to change notification settings - Fork55
An opinionated 2D game engine for Rust
License
hecrj/coffee
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
An opinionated 2D game engine for Rust focused on simplicity, explicitness, and type-safety.
Coffee is in a very early stage of development. Manybasic features are still missing, somedependencies are experimental, and there are probablymany bugs.Feel free to contribute!
- Responsive, customizable GUI
- Declarative, type-safe loading screens with progress tracking
- Built-indebug view with performance metrics
- Fixed, deterministic timestep
- Explicit, easy to use, hardware-accelerated 2D graphics API
- Multiplatform support leveraging OpenGL, Vulkan, Metal, D3D11, and D3D12
- Explicit and efficient batched draws
- Mesh support
- Texture array support
- Off-screen rendering
- TrueType font rendering
- Gamepad support
And more! Check out theexamples to see them in action.
Addcoffee
as a dependency in yourCargo.toml
and enable a graphics backendfeature (opengl
,vulkan
,metal
,dx11
, ordx12
):
coffee = {version ="0.4",features = ["opengl"] }
Rust is quite slow in debug mode. If you experience performance issues whendrawing hundreds of sprites, enable compiler optimizations in yourCargo.toml
.I recommend level 2 optimizations in order to stay closer to--release
performance:
[profile.dev]opt-level =2
Coffee moves fast and themaster
branch can contain breaking changes! Ifyou want to learn about a specific release, check outthe release list.
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};fnmain() ->Result<()>{MyGame::run(WindowSettings{title:String::from("A caffeinated game"),size:(1280,1024),resizable:true,fullscreen:false,maximized:false,})}structMyGame{// Your game state and assets go here...}implGameforMyGame{typeInput =();// No input datatypeLoadingScreen =();// No loading screenfnload(_window:&Window) ->Task<MyGame>{// Load your game assets here. Check out the `load` module!Task::succeed(||MyGame{/* ... */})}fndraw(&mutself,frame:&mutFrame,_timer:&Timer){// Clear the current frame frame.clear(Color::BLACK);// Draw your game here. Check out the `graphics` module!}}
Browse thedocumentation and theexamples to learn more!
Coffee builds upon
winit
for windowing and mouse/keyboard events.gfx
pre-ll for OpenGL support, based heavily on theggez
codebase.wgpu
forexperimental 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 thePoint
,Vector
, andTransformation
types.image
for image loading and texture array building.
I am quite new to Rust, systems programming, and computer graphics. I amlearning along the way as I build the engine for a game I am currentlydeveloping. I am always glad to to learn from anyone.
If you want to contribute, you are more than welcome to be a part of theproject! Check out the currentissues if you want to find something to workon. Try to share you thoughts first! Feel free to open a new issue if you wantto 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 theRust Community Discord. I go by@lone_scientist
there.
ggez
, an awesome, easy-to-use, good game engine that introduced me toRust. Its graphics implementation served me as a guide to implement OpenGLsupport for Coffee.- Kenney, creators of amazing free game assets with no strings attached. Thebuilt-in GUI renderer in Coffee uses a modified version of their UI sprites.
About
An opinionated 2D game engine for Rust