Move renderer code into a struct (ADT)
This commit is contained in:
+8
-2
@@ -1,16 +1,21 @@
|
||||
|
||||
pub mod structs;
|
||||
|
||||
use sdl3::{pixels::Color, rect::Rect, render::Canvas, sys::metadata::render, ttf::Font, video::Window};
|
||||
use sdl3::{Sdl, pixels::Color, rect::Rect, render::Canvas, sys::metadata::render, ttf::Font, video::Window};
|
||||
use structs::{Prefs};
|
||||
|
||||
pub struct Screen<'a> {
|
||||
canvas: Box<Canvas<Window>>,
|
||||
font: Box<Font<'a>>
|
||||
font: Box<Font<'a>>,
|
||||
context: Box<Sdl>
|
||||
}
|
||||
|
||||
impl Screen<'_> {
|
||||
|
||||
pub fn get_context(&self) -> &Sdl {
|
||||
return &self.context;
|
||||
}
|
||||
|
||||
pub fn print(&mut self, line: u32, text: &str) {
|
||||
let rendered_text = self.font.render(text).solid(Color::RED).unwrap();
|
||||
let texture_creator = self.canvas.texture_creator();
|
||||
@@ -49,6 +54,7 @@ impl Screen<'_> {
|
||||
let mut screen: Screen = Screen {
|
||||
canvas: Box::new(window.into_canvas()),
|
||||
font: Box::new(font),
|
||||
context: Box::new(sdl_context),
|
||||
};
|
||||
|
||||
screen.clear();
|
||||
|
||||
Reference in New Issue
Block a user