1use sdl3::{
4 keyboard::{Keycode, Mod, Scancode},
5 mouse::{MouseButton, MouseState, MouseWheelDirection},
6};
7
8use crate::graphics::Graphics;
9
10pub mod events;
12pub mod graphics;
14
15pub struct Game {
20 pub name: String,
22 pub author: String,
24 pub graphics: Graphics,
26}
27
28impl Game {
29 pub fn new(name: String, author: String, graphics: Graphics) -> Game {
39 Game {
40 name,
41 author,
42 graphics,
43 }
44 }
45}
46
47pub trait EventHandler {
53 fn update(&self, game: &mut Game) -> anyhow::Result<()>;
54 fn draw(&self, game: &mut Game) -> anyhow::Result<()>;
55 fn key_down_event(
56 &self,
57 _game: &mut Game,
58 _timestamp: u64,
59 _window_id: u32,
60 _keycode: Option<Keycode>,
61 _scancode: Option<Scancode>,
62 _keymod: Mod,
63 _repeat: bool,
64 _which: u32,
65 _raw: u16,
66 ) -> anyhow::Result<()> {
67 Ok(())
68 }
69
70 fn key_up_event(
71 &self,
72 _game: &mut Game,
73 _timestamp: u64,
74 _window_id: u32,
75 _keycode: Option<Keycode>,
76 _scancode: Option<Scancode>,
77 _keymod: Mod,
78 _repeat: bool,
79 _which: u32,
80 _raw: u16,
81 ) -> anyhow::Result<()> {
82 Ok(())
83 }
84
85 fn mouse_motion_event(
86 &self,
87 _game: &mut Game,
88 _timestamp: u64,
89 _window_id: u32,
90 _which: u32,
91 _mousestate: MouseState,
92 _x: f32,
93 _y: f32,
94 _xrel: f32,
95 _yrel: f32,
96 ) -> anyhow::Result<()> {
97 Ok(())
98 }
99
100 fn mouse_button_down_event(
101 &self,
102 _game: &mut Game,
103 _timestamp: u64,
104 _window_id: u32,
105 _which: u32,
106 _mouse_btn: MouseButton,
107 _clicks: u8,
108 _x: f32,
109 _y: f32,
110 ) -> anyhow::Result<()> {
111 Ok(())
112 }
113
114 fn mouse_button_up_event(
115 &self,
116 _game: &mut Game,
117 _timestamp: u64,
118 _window_id: u32,
119 _which: u32,
120 _mouse_btn: MouseButton,
121 _clicks: u8,
122 _x: f32,
123 _y: f32,
124 ) -> anyhow::Result<()> {
125 Ok(())
126 }
127
128 fn mouse_wheel_event(
129 &self,
130 _game: &mut Game,
131 _timestamp: u64,
132 _window_id: u32,
133 _which: u32,
134 _x: f32,
135 _y: f32,
136 _direction: MouseWheelDirection,
137 _mouse_x: f32,
138 _mouse_y: f32,
139 ) -> anyhow::Result<()> {
140 Ok(())
141 }
142}