Skip to content

Commit

Permalink
Update README and camera matrix
Browse files Browse the repository at this point in the history
  • Loading branch information
XavierCS-dev committed Mar 11, 2024
1 parent bbbb220 commit 15de132
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
- [ ] Hide main loop from user, or at least, make it easier to use
- [ ] Event System
- [ ] Provide a method to set a background image
- [ ] Fix camera stretching

- [x] Further goals (0.2.0 release blockers)
- [x] Implement Transformation2D
Expand Down
7 changes: 6 additions & 1 deletion src/engine/camera/camera.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,12 @@ impl Camera2D {
let proj_mat = Matrix4::from_slice([
[1.0 / (aspect_ratio * (fov_rad / 2.0).tan()), 0.0, 0.0, 0.0],
[0.0, 1.0 / ((fov_rad / 2.0).tan()), 0.0, 0.0],
[0.0, 0.0, far / (far - near), -(far * near) / (far - near)],
[
0.0,
0.0,
0.5 * far / (far - near),
-(far * near) / (far - near),
],
[0.0, 0.0, 0.0, 1.0],
]);
let buffer = device.create_buffer_init(&wgpu::util::BufferInitDescriptor {
Expand Down
7 changes: 4 additions & 3 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use winit::{

fn main() {
println!("Hello, world!");
let (mut app, event_loop) = effect_engine::init_engine(PhysicalSize::new(800, 600), 90.0);
let (mut app, event_loop) = effect_engine::init_engine(PhysicalSize::new(800, 600), 45.0);
let mut before = Instant::now();
let mut after = Instant::now();
let tex_id = TextureID("tree");
Expand All @@ -26,11 +26,12 @@ fn main() {
.init_layer(layer_id, vec![tex, evil], PhysicalSize::new(32, 32))
.unwrap();
let position = Vector3::new(-0.5, -0.5, 0.0);
let ent = app.init_entity(position, evil_id, &mut layer);
let mut ent = app.init_entity(position, evil_id, &mut layer);
let mut ent_good = app.init_entity(position, tex_id, &mut layer);
EntitySystem2D::set_position(&mut ent_good, Vector3::new(0.0, 0.0, 0.0));
EntitySystem2D::set_rotation(&mut ent_good, 30.0);
EntitySystem2D::set_scale(&mut ent_good, 0.25);
EntitySystem2D::set_scale(&mut ent, 0.5);
let mut ents_owner = vec![ent, ent_good];
let mut ents = Vec::new();
for ent in ents_owner.iter() {
Expand All @@ -40,7 +41,7 @@ fn main() {
drop(ents);
let mut layers = vec![layer];
let camera = app.camera_mut();
Camera2DSystem::transform(camera, Vector3::new(-0.5, -0.5, 0.0));
Camera2DSystem::transform(camera, Vector3::new(-1.0, -1.0, 0.0));
app.update_camera();

let mut rotation = 0.0;
Expand Down

0 comments on commit 15de132

Please sign in to comment.