Minor rename

master
Mark 2023-12-25 08:46:10 -08:00
parent b2e9f64c91
commit 50bd3bdb8c
Signed by: Mark
GPG Key ID: C6D63995FE72FD80
5 changed files with 10 additions and 12 deletions

View File

@ -6,7 +6,7 @@ pub struct Doodad {
pub sprite: SpriteTexture,
pub pos: Point2<Pfloat>,
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,
};
}

View File

@ -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(),
})
}

View File

@ -2,7 +2,7 @@
struct InstanceInput {
@location(2) position: vec2<f32>,
@location(3) parallax: f32,
@location(4) height: f32,
@location(4) size: f32,
@location(5) tint: vec2<f32>,
};
@ -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;

View File

@ -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,

View File

@ -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(),
};
}
}