summaryrefslogtreecommitdiff
path: root/crates/client/src/client.rs
blob: 2c032864217a444c5e2586f61244bccea16c9be8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#![allow(dead_code, unused_variables)]
mod assets;

use std::collections::HashMap;
use teleia::*;

pub struct Game {
    assets: assets::Assets,
}

impl Game {
    pub 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, _ctx: &context::Context, _st: &mut state::State) -> Erm<()> { Ok(()) }
    fn mouse_press(&mut self, _ctx: &context::Context, _st: &mut state::State) -> Erm<()> { Ok(()) }
    fn mouse_move(&mut self, _ctx: &context::Context, _st: &mut state::State, _x: i32, _y: i32) -> Erm<()> { Ok(()) }
    fn update(&mut self, ctx: &context::Context, _st: &mut state::State) -> Erm<()> {
        Ok(())
    }
    fn render(&mut self, ctx: &context::Context, st: &mut state::State) -> Erm<()> {
        ctx.clear();
        self.assets.font.render_text(
            ctx, st,
            &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, st,
            &glam::Vec2::new(40.0, 40.0),
            &glam::Vec2::new(16.0, 16.0),
        );
        self.assets.mesh_square.render(ctx);
        Ok(())
    }
}