moved camera to a separate mod and use Rect intersection and has_intersection methods

This commit is contained in:
2015-01-06 16:07:03 +01:00
parent 62c74a0736
commit db4b16c08d
2 changed files with 48 additions and 63 deletions

24
src/camera.rs Normal file
View File

@@ -0,0 +1,24 @@
use sdl2::rect::Rect;
pub struct Camera {
pub x: i32,
pub y: i32,
pub w: i32,
pub h: i32
}
impl Camera {
pub fn new(x: i32, y: i32, w: i32, h: i32) -> Camera {
Camera {
x: x,
y: y,
w: w,
h: h
}
}
pub fn get_rect(&self) -> Rect {
Rect::new(self.x, self.y, self.w, self.h)
}
}