|
|
@ -5,7 +5,7 @@ pub struct Sprite {
|
|
|
|
pub vertices: [(f32, f32); 6],
|
|
|
|
pub vertices: [(f32, f32); 6],
|
|
|
|
|
|
|
|
|
|
|
|
position: (f32, f32),
|
|
|
|
position: (f32, f32),
|
|
|
|
size: (u32, u32),
|
|
|
|
size: (f32, f32),
|
|
|
|
color: (f32, f32, f32, f32),
|
|
|
|
color: (f32, f32, f32, f32),
|
|
|
|
|
|
|
|
|
|
|
|
textured: bool,
|
|
|
|
textured: bool,
|
|
|
@ -16,11 +16,11 @@ pub struct Sprite {
|
|
|
|
|
|
|
|
|
|
|
|
impl Sprite {
|
|
|
|
impl Sprite {
|
|
|
|
|
|
|
|
|
|
|
|
pub fn new(position: (f32, f32), size: (u32, u32)) -> Sprite {
|
|
|
|
pub fn new(position: (f32, f32), size: (f32, f32)) -> Sprite {
|
|
|
|
Sprite::new_with_color(position, size, (0.,0.,0.,0.))
|
|
|
|
Sprite::new_with_color(position, size, (0.,0.,0.,0.))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
pub fn new_with_color(position: (f32, f32), size: (u32, u32), color: (f32, f32, f32, f32)) -> Sprite {
|
|
|
|
pub fn new_with_color(position: (f32, f32), size: (f32, f32), color: (f32, f32, f32, f32)) -> Sprite {
|
|
|
|
|
|
|
|
|
|
|
|
let fsize = (size.0 as f32, size.1 as f32);
|
|
|
|
let fsize = (size.0 as f32, size.1 as f32);
|
|
|
|
|
|
|
|
|
|
|
@ -42,7 +42,7 @@ impl Sprite {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
pub fn new_with_texture(position: (f32, f32), size: (u32, u32), texture_id: String) -> Sprite {
|
|
|
|
pub fn new_with_texture(position: (f32, f32), size: (f32, f32), texture_id: String) -> Sprite {
|
|
|
|
|
|
|
|
|
|
|
|
let fsize = (size.0 as f32, size.1 as f32);
|
|
|
|
let fsize = (size.0 as f32, size.1 as f32);
|
|
|
|
|
|
|
|
|
|
|
@ -55,8 +55,8 @@ impl Sprite {
|
|
|
|
(position.0 + fsize.0, position.1 + fsize.1 ), // bottom right
|
|
|
|
(position.0 + fsize.0, position.1 + fsize.1 ), // bottom right
|
|
|
|
(position.0 + fsize.0, position.1 ), // top right
|
|
|
|
(position.0 + fsize.0, position.1 ), // top right
|
|
|
|
],
|
|
|
|
],
|
|
|
|
position,
|
|
|
|
position: position,
|
|
|
|
size,
|
|
|
|
size: size,
|
|
|
|
color: (0.0, 0.0, 0.0, 0.0),
|
|
|
|
color: (0.0, 0.0, 0.0, 0.0),
|
|
|
|
textured: false,
|
|
|
|
textured: false,
|
|
|
|
texture_id: Some(texture_id)
|
|
|
|
texture_id: Some(texture_id)
|
|
|
|