Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
game: improving diag hud and consolidating cameras
- Loading branch information
Showing
9 changed files
with
92 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
use sdl2::rect::Point; | ||
|
||
pub struct Cameras { | ||
pub platform: Point, | ||
} | ||
|
||
impl Cameras { | ||
pub fn new() -> Cameras { | ||
Cameras { | ||
platform: Point::new(0, 0), | ||
} | ||
} | ||
pub fn update(&mut self, player_coords: &Point, window_size: &(u32, u32)) { | ||
let center_screen = Point::new((window_size.0 / 2) as i32, (window_size.1 / 2) as i32); | ||
let centered = Point::new( | ||
player_coords.x - center_screen.x, | ||
player_coords.y - center_screen.y, | ||
); | ||
|
||
self.platform = centered; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
pub mod cameras; | ||
pub mod diagnostics; | ||
pub mod player; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
pub mod diag_hud; | ||
pub mod hud_diagnostics; | ||
pub mod floor_view; | ||
pub mod grid_view; | ||
pub mod player_view; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters