summaryrefslogtreecommitdiff
path: root/crates/client/src/common/client.rs
diff options
context:
space:
mode:
authorLLLL Colonq <llll@colonq>2025-02-16 22:55:43 -0500
committerLLLL Colonq <llll@colonq>2025-02-16 22:55:43 -0500
commit4d0a8140130ebd0f46744b86eeb2a708657a942e (patch)
tree6b1a11e07173c769d0f3522c2f6088409b69332d /crates/client/src/common/client.rs
parent33d69b282e082acce3c5d36cc08cd99a7ccf738d (diff)
Switch to workspace
Diffstat (limited to 'crates/client/src/common/client.rs')
-rw-r--r--crates/client/src/common/client.rs48
1 files changed, 48 insertions, 0 deletions
diff --git a/crates/client/src/common/client.rs b/crates/client/src/common/client.rs
new file mode 100644
index 0000000..69ac6b3
--- /dev/null
+++ b/crates/client/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<String, audio::Audio> {
+ 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(())
+ }
+}