game_loop_root/
game-loop-root.rs1use gemini_engine::gameloop::MainLoopRoot;
4use gemini_engine::{
5 core::{ColChar, Vec2D},
6 primitives::Pixel,
7 view::{View, WrappingMode},
8};
9
10struct Game {
11 view: View,
12 pixel: Pixel,
13}
14
15impl Game {
16 fn new() -> Self {
17 Self {
18 view: View::new(40, 8, ColChar::BACKGROUND).with_wrapping_mode(WrappingMode::Wrap),
19 pixel: Pixel::new(Vec2D { x: 10, y: 5 }, ColChar::SOLID),
20 }
21 }
22}
23
24impl MainLoopRoot for Game {
25 fn get_fps(&self) -> f32 {
26 30.0
27 }
28
29 fn frame(&mut self) {
30 self.pixel.pos.x += 1;
31 }
32
33 fn render_frame(&mut self) {
34 self.view.clear();
35 self.view.draw(&self.pixel);
36 let _ = self.view.display_render();
37 }
38}
39
40fn main() {
41 let mut game = Game::new();
42
43 game.main_loop();
44}