feat(ecs): added utility methods

This commit is contained in:
lisk77 2025-07-25 00:25:56 +02:00
parent 67ac2f90e4
commit 0da5200916

View file

@ -227,8 +227,11 @@ impl Position3D {
}
impl Rectangle2D {
pub fn new(position: Position2D, size: v2) -> Self {
Self { position, size }
pub fn with_size(width: f32, height: f32) -> Self {
Self {
position: Position2D::from_vec(v2::new(0.0, 0.0)),
size: v2::new(width, height),
}
}
pub fn position(&self) -> Position2D {
@ -262,6 +265,16 @@ impl Collider for Rectangle2D {
}
}
impl Render2D {
pub fn with_texture(texture: &'static str) -> Self {
Self {
is_visible: true,
texture_name: texture,
scale: v2::new(1.0, 1.0),
}
}
}
impl Render for Render2D {
fn is_visible(&self) -> bool {
self.is_visible