Scale cleanup
parent
cb9e7a602f
commit
144fe78b85
|
@ -27,7 +27,7 @@ impl Drawable for Doodad {
|
|||
) -> Result<(), String> {
|
||||
let pos = self.screen_position(canvas, c);
|
||||
let sprite = sa.get(&self.sprite);
|
||||
sprite.draw(canvas, pos, self.angle)?;
|
||||
sprite.draw(canvas, pos, self.angle, 1.0)?;
|
||||
return Ok(());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -35,7 +35,7 @@ impl Drawable for Ship {
|
|||
) -> Result<(), String> {
|
||||
let pos = self.screen_position(canvas, c);
|
||||
let sprite = sa.get(self.kind.sprite());
|
||||
sprite.draw(canvas, pos, self.body.angle.to_degrees())?;
|
||||
sprite.draw(canvas, pos, self.body.angle.to_degrees(), 1.0)?;
|
||||
return Ok(());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,10 +26,12 @@ impl<'a> Sprite<'a> {
|
|||
canvas: &mut Canvas<Window>,
|
||||
position: PhysVec,
|
||||
angle: f64,
|
||||
scale: f64,
|
||||
) -> Result<(), String> {
|
||||
let win_size = PhysVec::from(canvas.window().size());
|
||||
let width = self.rect.width();
|
||||
let height = self.rect.height();
|
||||
let scale = scale * self.scale;
|
||||
|
||||
// Don't draw if we're not on the screen.
|
||||
// An offset is included to ensure we're completely
|
||||
|
@ -45,12 +47,12 @@ impl<'a> Sprite<'a> {
|
|||
let mut dest = Rect::new(
|
||||
0,
|
||||
0,
|
||||
(width as f64 / self.scale) as u32,
|
||||
(height as f64 / self.scale) as u32,
|
||||
(width as f64 * scale) as u32,
|
||||
(height as f64 * scale) as u32,
|
||||
);
|
||||
dest.center_on(Point::new(
|
||||
(width as f64 / (2.0 * self.scale)) as i32,
|
||||
(height as f64 / (2.0 * self.scale)) as i32,
|
||||
(width as f64 * scale / 2.0) as i32,
|
||||
(height as f64 * scale / 2.0) as i32,
|
||||
));
|
||||
|
||||
// set the current frame for time
|
||||
|
@ -64,8 +66,8 @@ impl<'a> Sprite<'a> {
|
|||
Some(dest),
|
||||
angle, // angle
|
||||
Point::new(
|
||||
(width as f64 / (2.0 * self.scale)) as i32,
|
||||
(height as f64 / (2.0 * self.scale)) as i32,
|
||||
(width as f64 * scale / 2.0) as i32,
|
||||
(height as f64 * scale / 2.0) as i32,
|
||||
), // center
|
||||
false,
|
||||
false,
|
||||
|
@ -88,7 +90,7 @@ impl<'a> SpriteAtlas<'a> {
|
|||
data: HashMap::new(),
|
||||
};
|
||||
|
||||
b.load_one(texture_creator, "gypsum.png", 1.5)?;
|
||||
b.load_one(texture_creator, "gypsum.png", 0.75)?;
|
||||
b.load_one(texture_creator, "a0.png", 1.0)?;
|
||||
b.load_one(texture_creator, "small.png", 1.0)?;
|
||||
b.load_one(texture_creator, "earth.png", 1.0)?;
|
||||
|
|
Loading…
Reference in New Issue