summaryrefslogtreecommitdiff
path: root/src/camera.rs
diff options
context:
space:
mode:
authortom barrett <spalf0@gmail.com>2019-06-18 11:19:49 -0500
committertom barrett <spalf0@gmail.com>2019-06-18 11:19:49 -0500
commit135bb9e7c37bbb226d3c676f2d87a67648bf35cb (patch)
treebebd562b897e1923668802bcad2eb322cf090ee5 /src/camera.rs
parentc510d4a406218c38e1146503473e9e10c282a56d (diff)
got drawing of character
Diffstat (limited to 'src/camera.rs')
-rw-r--r--src/camera.rs20
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;
}
}