diff options
Diffstat (limited to 'examples/ggez/renderer.rs')
-rw-r--r-- | examples/ggez/renderer.rs | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/examples/ggez/renderer.rs b/examples/ggez/renderer.rs index ae6e3250..d21c5ec3 100644 --- a/examples/ggez/renderer.rs +++ b/examples/ggez/renderer.rs @@ -1,14 +1,31 @@ +mod button; mod text; -use ggez::graphics::{self, Color}; +use ggez::graphics::{self, spritebatch::SpriteBatch, Color, Image}; use ggez::Context; pub struct Renderer<'a> { pub context: &'a mut Context, + pub sprites: SpriteBatch, + pub spritesheet: Image, } impl Renderer<'_> { + pub fn new(context: &mut Context, spritesheet: Image) -> Renderer { + Renderer { + context, + sprites: SpriteBatch::new(spritesheet.clone()), + spritesheet, + } + } pub fn flush(&mut self) { + graphics::draw( + self.context, + &self.sprites, + graphics::DrawParam::default(), + ) + .expect("Draw sprites"); + graphics::draw_queued_text( self.context, graphics::DrawParam::default(), |