mirror of
https://github.com/lisk77/comet.git
synced 2025-10-23 13:38:48 +00:00
feat(ecs): added utility methods
This commit is contained in:
parent
67ac2f90e4
commit
0da5200916
1 changed files with 15 additions and 2 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue