2 releases
Uses new Rust 2024
| 0.1.1 | Aug 22, 2025 |
|---|---|
| 0.1.0 | Aug 22, 2025 |
#489 in Game dev
215KB
928 lines
wobl
multi-backend textbased game engine :)
use
use wobl::{Attribute, Color, Key, Wobl, backend::CrosstermBackend};
fn main() {
let backend = Box::new(CrosstermBackend::new());
let mut engine = Wobl::new(backend, 60, 30, Some(60));
loop {
engine.wait_frame();
engine.clear();
if engine.is_key_pressed(Key::Q) {
break;
}
engine.draw_text_atr(
10,
10,
"hello wobl!",
Color::Black,
Color::White,
&vec![Attribute::Italic, Attribute::Bold],
);
}
}
backends
backends are quite straight forward to implement. here are the included ones!
crossterm(woah terminal!): this should work pretty much everywhere: windows, linux (x11) and macos. if featurecrossterm_eventsis enabled then it uses terminal events (kittyprotocol), otherwise it usesdevice_query- enable it if using wayland (add--features crossterm_events)!sdl: for now - it just kinda works - i can definetly make more optimizations (like a texture atlas)
boilerplate can differ slightly from backend to backend, but only a couple of lines of code :)
crossterm:
let backend = Box::new(CrosstermBackend::new());
let mut engine = Wobl::new(backend, 50, 25, Some(60));
-sdl:
let sdl_context = sdl2::init().unwrap();
let ttf_context: &Sdl2TtfContext = Box::leak(Box::new(sdl2::ttf::init().unwrap()));
let backend = Box::new(SDLBackend::new(
30,
"resources/font.ttf",
ttf_context,
sdl_context,
));
let mut wobl = Wobl::new(backend, "Colorful Wobl Demo", 50, 25, Some(60));
loop {...}
to do
- [] add more utilities:
- [] line drawing
- [] box drawing
- [] autotile
- [] use font atlas thing in
sdl - [] maybe
winitandwgpubackend
Dependencies
~18–47MB
~768K SLoC