diff --git a/src/doodad.rs b/src/doodad.rs index 4cd0dcf..bcd2491 100644 --- a/src/doodad.rs +++ b/src/doodad.rs @@ -6,7 +6,7 @@ pub struct Doodad { pub sprite: SpriteTexture, pub pos: Point2, pub parallax: Pfloat, - pub height: Pfloat, + pub size: Pfloat, } impl Spriteable for Doodad { @@ -16,7 +16,7 @@ impl Spriteable for Doodad { pos: self.pos, angle: Deg(0.0), scale: 1.0, - height: self.height, + size: self.size, parallax: self.parallax, }; } diff --git a/src/render/gpustate.rs b/src/render/gpustate.rs index e5682b6..09dda6b 100644 --- a/src/render/gpustate.rs +++ b/src/render/gpustate.rs @@ -223,7 +223,7 @@ impl GPUState { // Game dimensions of this sprite post-scale. // Don't divide by 2, we use this later. - let height = s.height * s.scale; + let height = s.size * s.scale; let width = height * texture.aspect; // Don't draw (or compute matrices for) @@ -311,7 +311,7 @@ impl GPUState { instances.push(StarfieldInstance { position: (s.pos + offset).into(), parallax: s.parallax, - height: s.height, + size: s.size, tint: s.tint.into(), }) } diff --git a/src/render/shaders/starfield.wgsl b/src/render/shaders/starfield.wgsl index b1a55c6..27b4355 100644 --- a/src/render/shaders/starfield.wgsl +++ b/src/render/shaders/starfield.wgsl @@ -2,7 +2,7 @@ struct InstanceInput { @location(2) position: vec2, @location(3) parallax: f32, - @location(4) height: f32, + @location(4) size: f32, @location(5) tint: vec2, }; @@ -57,7 +57,7 @@ fn vertex_shader_main( // Apply sprite aspect ratio & scale factor // also applies screen aspect ratio - var scale: f32 = instance.height / global.camera_zoom.x; + var scale: f32 = instance.size / global.camera_zoom.x; // Minimum scale to prevent flicker at large zoom levels var real_size = scale * global.window_size.xy; diff --git a/src/render/vertexbuffer/types.rs b/src/render/vertexbuffer/types.rs index 463121d..94ede28 100644 --- a/src/render/vertexbuffer/types.rs +++ b/src/render/vertexbuffer/types.rs @@ -44,9 +44,7 @@ pub struct StarfieldInstance { /// Parallax factor (same unit as usual) pub parallax: f32, - /// Height of (unrotated) sprite in world units - pub height: f32, - + pub size: f32, pub tint: [f32; 2], } @@ -68,7 +66,7 @@ impl BufferObject for StarfieldInstance { shader_location: 3, format: wgpu::VertexFormat::Float32, }, - // Height + // Size wgpu::VertexAttribute { offset: mem::size_of::<[f32; 3]>() as wgpu::BufferAddress, shader_location: 4, diff --git a/src/ship.rs b/src/ship.rs index ebc4016..695d0b4 100644 --- a/src/ship.rs +++ b/src/ship.rs @@ -15,7 +15,7 @@ impl ShipKind { return SpriteTexture(name.to_owned()); } - fn height(&self) -> Pfloat { + fn size(&self) -> Pfloat { match self { Self::Gypsum => 100.0, } @@ -44,7 +44,7 @@ impl Spriteable for Ship { angle: self.body.angle, scale: 1.0, parallax: 1.0, - height: self.kind.height(), + size: self.kind.size(), }; } }