feat: implemented a priority camera system that searches for the Entity with the Camera2D component with the smallest priority

This commit is contained in:
lisk77 2025-03-08 02:04:50 +01:00
parent 8b439cb0e8
commit 4af65ed961
3 changed files with 49 additions and 10 deletions

View file

@ -30,10 +30,13 @@ impl Camera {
}
pub fn build_view_projection_matrix(&self) -> cgmath::Matrix4<f32> {
OPENGL_TO_WGPU_MATRIX * cgmath::ortho(self.position.x() - self.dimension.x() / 2.0,
self.position.x() + self.dimension.x() / 2.0,
self.position.y() - self.dimension.y() / 2.0,
self.position.y() + self.dimension.y() / 2.0,
let zoomed_width = self.dimension.x() / self.zoom;
let zoomed_height = self.dimension.y() / self.zoom;
OPENGL_TO_WGPU_MATRIX * cgmath::ortho(self.position.x() - zoomed_width / 2.0,
self.position.x() + zoomed_width / 2.0,
self.position.y() - zoomed_height / 2.0,
self.position.y() + zoomed_height / 2.0,
1.0,
0.0)
}