2 releases

0.4.1 Jun 3, 2024
0.4.0 Jun 3, 2024

#406 in Game dev

Download history 188/week @ 2024-05-29 64/week @ 2024-06-05 6/week @ 2024-06-12

258 downloads per month

MIT/Apache

28KB
464 lines

egui-tetra2

This is an up-to-date and maintained fork of tesselode/egui-tetra, which has been archived. Issues and PRs welcome.

crates.io | docs

egui-tetra2 is a library that helps integrate egui, an immediate mode GUI library, with Tetra, a 2D game framework.

Basic example

use std::error::Error;

struct MainState;

impl egui_tetra2::State<Box<dyn Error>> for MainState {
	fn ui(
		&mut self,
		_ctx: &mut tetra::Context,
		egui_ctx: &egui::Context,
	) -> Result<(), Box<dyn Error>> {
		egui::CentralPanel::default().show(egui_ctx, |_ui| {
			egui::Window::new("hi!").show(egui_ctx, |ui| {
				ui.label("Hello world!");
			});
		});
		Ok(())
	}
}

fn main() -> Result<(), Box<dyn Error>> {
	tetra::ContextBuilder::new("example", 800, 600)
		.show_mouse(true)
		.build()?
		.run(|_| Ok(egui_tetra2::StateWrapper::new(MainState)))
}

License

This project is licensed under either of

at your option.

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in time by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Dependencies

~45MB
~634K SLoC