diff options
| author | Kai Stevenson <kai@kaistevenson.com> | 2026-08-15 11:36:10 -0700 |
|---|---|---|
| committer | Kai Stevenson <kai@kaistevenson.com> | 2026-08-15 11:36:10 -0700 |
| commit | b510f5fcf5335c5e26d65ca96d7ec16c2f050f5d (patch) | |
| tree | 697d6b6991bec52e5041c8cc35cc98e12197edcb /src | |
| parent | ab2d7e3150eb28f9a8fc4ce83c6477753bdbcee3 (diff) | |
wip
Diffstat (limited to 'src')
| -rw-r--r-- | src/camera.rs | 23 | ||||
| -rw-r--r-- | src/config.rs | 3 | ||||
| -rw-r--r-- | src/main.rs | 2 |
3 files changed, 12 insertions, 16 deletions
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; diff --git a/src/config.rs b/src/config.rs index 6e367eb..2e656d4 100644 --- a/src/config.rs +++ b/src/config.rs @@ -1,8 +1,5 @@ pub const WINDOW_TITLE: &str = "pxs"; -pub const PIXEL_BUFFER_WIDTH: u32 = 320; -pub const PIXEL_BUFFER_HEIGHT: u32 = 240; - pub const CHUNK_SIZE: u32 = 32; pub const CELLS_IN_CHUNK: usize = (CHUNK_SIZE * CHUNK_SIZE) as usize; diff --git a/src/main.rs b/src/main.rs index b5c19e0..483bfb2 100644 --- a/src/main.rs +++ b/src/main.rs @@ -143,7 +143,7 @@ impl RendererState { mip_level_count: 1, sample_count: 1, usage: wgpu::TextureUsages::TEXTURE_BINDING | wgpu::TextureUsages::COPY_DST, - format: surface_format, + format: wgpu_types::TextureFormat::Rgba8UnormSrgb, size: wgpu::Extent3d { width: size.width, height: size.height, |
