diff options
Diffstat (limited to 'src/camera.rs')
-rw-r--r-- | src/camera.rs | 20 |
1 files changed, 12 insertions, 8 deletions
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<f32>, + height: f32, + width: f32, } impl Camera { - pub fn new(draw: Point2<f32>) -> 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<f32>) {} -} - -impl Default for Camera { - fn default() -> Camera { - Camera::new(Point2::new(0.0, 0.0)) + pub fn give_center(&mut self, center: Point2<f32>) { + self.draw.x = (self.width / 2.0) - center.x; + self.draw.y = (self.height / 2.0) - center.y; } } |