Galactica/src/doodad.rs

22 lines
457 B
Rust
Raw Normal View History

2023-12-21 11:26:44 -08:00
use crate::DrawContext;
2023-12-20 19:05:12 -08:00
use crate::Drawable;
use crate::SpriteAtlas;
2023-12-21 11:26:44 -08:00
use crate::WorldPosition;
2023-12-20 19:05:12 -08:00
pub struct Doodad {
pub sprite: String,
2023-12-21 11:26:44 -08:00
pub pos: WorldPosition,
pub scale: u32,
pub angle: f64,
2023-12-20 19:05:12 -08:00
}
impl Drawable for Doodad {
2023-12-21 11:26:44 -08:00
fn draw(&self, dc: &mut DrawContext, sa: &SpriteAtlas) -> Result<(), String> {
let pos = self.pos.screen_position(dc);
2023-12-20 19:05:12 -08:00
let sprite = sa.get(&self.sprite);
2023-12-21 11:26:44 -08:00
sprite.draw(dc.canvas, pos, self.angle, 1.0)?;
2023-12-20 19:05:12 -08:00
return Ok(());
}
}