egui-tetra2

Crates.ioegui-tetra2
lib.rsegui-tetra2
version0.6.0
sourcesrc
created_at2024-06-03 06:45:27.875938
updated_at2024-09-30 11:22:53.854996
descriptionegui integration for Tetra
homepage
repositoryhttps://github.com/trevyn/egui-tetra2
max_upload_size
id1259766
size138,888
(trevyn)

documentation

https://docs.rs/egui-tetra2

README

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.

Commit count: 72

cargo fmt