Galactica/src/render/sprite.rs
2023-12-27 17:51:53 -08:00

46 lines
1008 B
Rust

use cgmath::{Deg, Point3};
use super::SpriteTexture;
pub struct Sprite {
/// The sprite texture to draw
pub texture: SpriteTexture,
/// This object's position, in world coordinates.
pub pos: Point3<f32>,
/// The size of this sprite,
/// given as height in world units.
pub size: f32,
/// This sprite's rotation
/// (relative to north, measured ccw)
pub angle: Deg<f32>,
/// Sprites that should be drawn relative to this sprite.
pub children: Option<Vec<SubSprite>>,
}
pub struct SubSprite {
/// The sprite texture to draw
pub texture: SpriteTexture,
/// This object's position, in world coordinates.
/// This is relative to this sprite's parent.
pub pos: Point3<f32>,
/// The size of this sprite,
/// given as height in world units.
pub size: f32,
/// This sprite's rotation
/// (relative to north, measured ccw)
/// Just as position, this is relative to this
/// subsprite's parent sprite.
pub angle: Deg<f32>,
}
pub trait Spriteable {
fn get_sprite(&self) -> Sprite;
}