From 135bb9e7c37bbb226d3c676f2d87a67648bf35cb Mon Sep 17 00:00:00 2001 From: tom barrett Date: Tue, 18 Jun 2019 11:19:49 -0500 Subject: got drawing of character --- src/camera.rs | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) (limited to 'src/camera.rs') diff --git a/src/camera.rs b/src/camera.rs index 1dc2db2..4ae0153 100644 --- a/src/camera.rs +++ b/src/camera.rs @@ -1,19 +1,23 @@ use ggez::nalgebra::Point2; +use ggez::Context; pub struct Camera { pub draw: Point2, + height: f32, + width: f32, } impl Camera { - pub fn new(draw: Point2) -> Camera { - Camera { draw } + pub fn new(context: &mut Context) -> Camera { + Camera { + draw: Point2::new(0.0, 0.0), + height: context.conf.window_mode.height, + width: context.conf.window_mode.width, + } } - pub fn give_center(&mut self, center: Point2) {} -} - -impl Default for Camera { - fn default() -> Camera { - Camera::new(Point2::new(0.0, 0.0)) + pub fn give_center(&mut self, center: Point2) { + self.draw.x = (self.width / 2.0) - center.x; + self.draw.y = (self.height / 2.0) - center.y; } } -- cgit v1.2.3