From b510f5fcf5335c5e26d65ca96d7ec16c2f050f5d Mon Sep 17 00:00:00 2001 From: Kai Stevenson Date: Sat, 15 Aug 2026 11:36:10 -0700 Subject: wip --- src/camera.rs | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) (limited to 'src/camera.rs') diff --git a/src/camera.rs b/src/camera.rs index edb7f29..3713b98 100644 --- a/src/camera.rs +++ b/src/camera.rs @@ -1,6 +1,6 @@ use crate::{ Input, - config::{CAMERA_MOVEMENT_SPEED, CHUNK_SIZE, PIXEL_BUFFER_HEIGHT, PIXEL_BUFFER_WIDTH}, + config::{CAMERA_MOVEMENT_SPEED, CHUNK_SIZE}, sim::{chunk::Chunk, world::World}, }; @@ -43,13 +43,13 @@ impl Camera { } pub fn screen_position_to_world(&self, screen_x: f64, screen_y: f64) -> (f64, f64) { - let camera_width = self.zoom * f64::from(PIXEL_BUFFER_WIDTH); - let camera_height = self.zoom * f64::from(PIXEL_BUFFER_HEIGHT); + let camera_width = self.zoom * f64::from(1600); + let camera_height = self.zoom * f64::from(1200); let camera_start_x = self.x - camera_width / 2.0; let camera_start_y = self.y - camera_height / 2.0; ( - (screen_x / PIXEL_BUFFER_WIDTH as f64 * camera_width) + camera_start_x, - (screen_y / PIXEL_BUFFER_HEIGHT as f64 * camera_height) + camera_start_y, + (screen_x / 1600 as f64 * camera_width) + camera_start_x, + (screen_y / 1200 as f64 * camera_height) + camera_start_y, ) } @@ -58,9 +58,9 @@ impl Camera { for i in 0..frame.len() / 4 { let idx = i * 4; - frame[idx] = 0xFF; - frame[idx + 1] = 0xAA; - frame[idx + 2] = 0xAA; + frame[idx] = (i / 1000) as u8; + frame[idx + 1] = 0x00; + frame[idx + 2] = 0x00; frame[idx + 3] = 0xFF; } return; @@ -72,8 +72,7 @@ impl Camera { // world-space rect covered by the screen let (xl, yl) = self.screen_position_to_world(0.0, 0.0); - let (xu, yu) = - self.screen_position_to_world(PIXEL_BUFFER_WIDTH as f64, PIXEL_BUFFER_HEIGHT as f64); + let (xu, yu) = self.screen_position_to_world(1600 as f64, 1200 as f64); let c = CHUNK_SIZE as i32; let cx0 = (xl.floor() as i32).div_euclid(c); @@ -104,8 +103,8 @@ impl Camera { scale: f64, ) { let c = CHUNK_SIZE as i32; - let w = PIXEL_BUFFER_WIDTH as i32; - let h = PIXEL_BUFFER_HEIGHT as i32; + let w = 1600 as i32; + let h = 1200 as i32; for ly in 0..c { let wy = (cy * c + ly) as f64; -- cgit v1.3.1