~starkingdoms/starkingdoms

ref: 4174a429888ef87273b8513556a6a259b52798b9 starkingdoms/crates/client/src/components.rs -rw-r--r-- 717 bytes
4174a429 — ghostly_zsh camera and other transform added, also bevy 8 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
use bevy_ecs::{component::Component, system::Resource};
use nalgebra::{Matrix4, Rotation3, Scale3, Translation3};

#[derive(Component)]
pub struct Texture {
    pub name: String,
}

#[derive(Component, Debug)]
pub struct Transform {
    pub translation: Translation3<f32>,
    pub rotation: Rotation3<f32>,
    pub scale: Scale3<f32>,
}
impl Transform {
    pub fn to_matrix(&self) -> Matrix4<f32> {
        self.translation.to_homogeneous() * self.rotation.to_homogeneous() * self.scale.to_homogeneous()
    }
}

#[derive(Resource, Debug)]
pub struct Camera {
    pub x: f32,
    pub y: f32,
    pub zoom: f32,
    pub width: u32, // screen width (these are for aspect ratio)
    pub height: u32, // screen height
}