From 23d651bbad510f14484cf1c0a8081ffff890565e Mon Sep 17 00:00:00 2001 From: LLLL Colonq Date: Tue, 28 Jan 2025 12:03:11 -0500 Subject: Working overlay --- src/common/client.rs | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 src/common/client.rs (limited to 'src/common/client.rs') diff --git a/src/common/client.rs b/src/common/client.rs new file mode 100644 index 0000000..69ac6b3 --- /dev/null +++ b/src/common/client.rs @@ -0,0 +1,48 @@ +#![allow(dead_code, unused_variables)] +mod assets; + +use std::collections::HashMap; +use teleia::*; + +pub struct Game { + assets: assets::Assets, +} + +impl Game { + pub async fn new(ctx: &context::Context) -> Self { + Self { + assets: assets::Assets::new(ctx), + } + } +} + +impl teleia::state::Game for Game { + fn initialize_audio(&self, ctx: &context::Context, st: &state::State, actx: &audio::Context) -> HashMap { + HashMap::from_iter(vec![ + ("test".to_owned(), audio::Audio::new(&actx, include_bytes!("client/assets/audio/test.wav"))), + ]) + } + fn finish_title(&mut self, _st: &mut state::State) {} + fn mouse_press(&mut self, _ctx: &context::Context, _st: &mut state::State) {} + fn mouse_move(&mut self, _ctx: &context::Context, _st: &mut state::State, _x: i32, _y: i32) {} + fn update(&mut self, ctx: &context::Context, _st: &mut state::State) -> Option<()> { + Some(()) + } + fn render(&mut self, ctx: &context::Context, st: &mut state::State) -> Option<()> { + ctx.clear(); + self.assets.font.render_text( + ctx, + &glam::Vec2::new(0.0, 0.0), + "hello computer", + ); + st.bind_2d(ctx, &self.assets.shader_flat); + self.assets.texture_test.bind(ctx); + self.assets.shader_flat.set_position_2d( + ctx, + &glam::Vec2::new(40.0, 40.0), + &glam::Vec2::new(16.0, 16.0), + ); + self.assets.mesh_square.render(ctx); + Some(()) + } +} -- cgit v1.2.3