diff options
author | BigBrotherNii <nicochr1004@gmail.com> | 2024-07-16 20:06:41 +0200 |
---|---|---|
committer | BigBrotherNii <nicochr1004@gmail.com> | 2024-07-16 20:06:41 +0200 |
commit | fb30f4d264863291aaa879fb6f0908d54f346b00 (patch) | |
tree | cc28dc41676988e6f83dcafb84aa207206b4a312 /light-client/src/render/sprite.rs | |
parent | cceabfdfe7890ab03b0b07a445af34ec9a302366 (diff) | |
parent | 0ce6279d355d3d0311b7a3f5fbcb22a305bb0278 (diff) | |
download | hurrycurry-fb30f4d264863291aaa879fb6f0908d54f346b00.tar hurrycurry-fb30f4d264863291aaa879fb6f0908d54f346b00.tar.bz2 hurrycurry-fb30f4d264863291aaa879fb6f0908d54f346b00.tar.zst |
post merge textures
Diffstat (limited to 'light-client/src/render/sprite.rs')
-rw-r--r-- | light-client/src/render/sprite.rs | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/light-client/src/render/sprite.rs b/light-client/src/render/sprite.rs index c19f8392..711f45bf 100644 --- a/light-client/src/render/sprite.rs +++ b/light-client/src/render/sprite.rs @@ -22,7 +22,7 @@ impl Sprite { } } pub fn new_tile(src: Rect) -> Self { - Self::new(src, Vec2::new(0.5, 1.0), 0.) + Self::new(src, Vec2::new(0.5, 1.0), 0.5) } pub fn at(&self, pos: Vec2) -> SpriteDraw { SpriteDraw { @@ -34,17 +34,30 @@ impl Sprite { self.relative_dst.w, self.relative_dst.h, ), + tint: [0xff; 4], } } } #[derive(Debug, Clone, Copy)] pub struct SpriteDraw { + pub tint: [u8; 4], pub z_order: i32, pub src: Rect, pub dst: FRect, } +impl SpriteDraw { + pub fn overlay(src: Rect, pos: Vec2, size: Vec2, tint: Option<[u8; 4]>) -> Self { + Self { + dst: FRect::new(pos.x, pos.y, size.x, size.y), + src, + tint: tint.unwrap_or([0xff; 4]), + z_order: i32::MAX, + } + } +} + impl Ord for SpriteDraw { fn cmp(&self, other: &Self) -> std::cmp::Ordering { self.z_order.cmp(&other.z_order) |