Minor rename
parent
b2e9f64c91
commit
50bd3bdb8c
|
@ -6,7 +6,7 @@ pub struct Doodad {
|
||||||
pub sprite: SpriteTexture,
|
pub sprite: SpriteTexture,
|
||||||
pub pos: Point2<Pfloat>,
|
pub pos: Point2<Pfloat>,
|
||||||
pub parallax: Pfloat,
|
pub parallax: Pfloat,
|
||||||
pub height: Pfloat,
|
pub size: Pfloat,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Spriteable for Doodad {
|
impl Spriteable for Doodad {
|
||||||
|
@ -16,7 +16,7 @@ impl Spriteable for Doodad {
|
||||||
pos: self.pos,
|
pos: self.pos,
|
||||||
angle: Deg(0.0),
|
angle: Deg(0.0),
|
||||||
scale: 1.0,
|
scale: 1.0,
|
||||||
height: self.height,
|
size: self.size,
|
||||||
parallax: self.parallax,
|
parallax: self.parallax,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -223,7 +223,7 @@ impl GPUState {
|
||||||
|
|
||||||
// Game dimensions of this sprite post-scale.
|
// Game dimensions of this sprite post-scale.
|
||||||
// Don't divide by 2, we use this later.
|
// 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;
|
let width = height * texture.aspect;
|
||||||
|
|
||||||
// Don't draw (or compute matrices for)
|
// Don't draw (or compute matrices for)
|
||||||
|
@ -311,7 +311,7 @@ impl GPUState {
|
||||||
instances.push(StarfieldInstance {
|
instances.push(StarfieldInstance {
|
||||||
position: (s.pos + offset).into(),
|
position: (s.pos + offset).into(),
|
||||||
parallax: s.parallax,
|
parallax: s.parallax,
|
||||||
height: s.height,
|
size: s.size,
|
||||||
tint: s.tint.into(),
|
tint: s.tint.into(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
struct InstanceInput {
|
struct InstanceInput {
|
||||||
@location(2) position: vec2<f32>,
|
@location(2) position: vec2<f32>,
|
||||||
@location(3) parallax: f32,
|
@location(3) parallax: f32,
|
||||||
@location(4) height: f32,
|
@location(4) size: f32,
|
||||||
@location(5) tint: vec2<f32>,
|
@location(5) tint: vec2<f32>,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -57,7 +57,7 @@ fn vertex_shader_main(
|
||||||
|
|
||||||
// Apply sprite aspect ratio & scale factor
|
// Apply sprite aspect ratio & scale factor
|
||||||
// also applies screen aspect ratio
|
// 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
|
// Minimum scale to prevent flicker at large zoom levels
|
||||||
var real_size = scale * global.window_size.xy;
|
var real_size = scale * global.window_size.xy;
|
||||||
|
|
|
@ -44,9 +44,7 @@ pub struct StarfieldInstance {
|
||||||
/// Parallax factor (same unit as usual)
|
/// Parallax factor (same unit as usual)
|
||||||
pub parallax: f32,
|
pub parallax: f32,
|
||||||
|
|
||||||
/// Height of (unrotated) sprite in world units
|
pub size: f32,
|
||||||
pub height: f32,
|
|
||||||
|
|
||||||
pub tint: [f32; 2],
|
pub tint: [f32; 2],
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -68,7 +66,7 @@ impl BufferObject for StarfieldInstance {
|
||||||
shader_location: 3,
|
shader_location: 3,
|
||||||
format: wgpu::VertexFormat::Float32,
|
format: wgpu::VertexFormat::Float32,
|
||||||
},
|
},
|
||||||
// Height
|
// Size
|
||||||
wgpu::VertexAttribute {
|
wgpu::VertexAttribute {
|
||||||
offset: mem::size_of::<[f32; 3]>() as wgpu::BufferAddress,
|
offset: mem::size_of::<[f32; 3]>() as wgpu::BufferAddress,
|
||||||
shader_location: 4,
|
shader_location: 4,
|
||||||
|
|
|
@ -15,7 +15,7 @@ impl ShipKind {
|
||||||
return SpriteTexture(name.to_owned());
|
return SpriteTexture(name.to_owned());
|
||||||
}
|
}
|
||||||
|
|
||||||
fn height(&self) -> Pfloat {
|
fn size(&self) -> Pfloat {
|
||||||
match self {
|
match self {
|
||||||
Self::Gypsum => 100.0,
|
Self::Gypsum => 100.0,
|
||||||
}
|
}
|
||||||
|
@ -44,7 +44,7 @@ impl Spriteable for Ship {
|
||||||
angle: self.body.angle,
|
angle: self.body.angle,
|
||||||
scale: 1.0,
|
scale: 1.0,
|
||||||
parallax: 1.0,
|
parallax: 1.0,
|
||||||
height: self.kind.height(),
|
size: self.kind.size(),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue