diff options
author | metamuffin <metamuffin@disroot.org> | 2024-07-16 18:05:29 +0200 |
---|---|---|
committer | metamuffin <metamuffin@disroot.org> | 2024-07-16 18:05:29 +0200 |
commit | 511199443a419f549aeb500d7b013baef10152de (patch) | |
tree | 10fb8dd4b9166e57d95ad0d31a1a45734745ebd0 /light-client/src/render/sprite.rs | |
parent | 9dfc5afb299ed74b277735bcf06f47b52f68caee (diff) | |
download | hurrycurry-511199443a419f549aeb500d7b013baef10152de.tar hurrycurry-511199443a419f549aeb500d7b013baef10152de.tar.bz2 hurrycurry-511199443a419f549aeb500d7b013baef10152de.tar.zst |
refactor renderer again
Diffstat (limited to 'light-client/src/render/sprite.rs')
-rw-r--r-- | light-client/src/render/sprite.rs | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/light-client/src/render/sprite.rs b/light-client/src/render/sprite.rs index 942db611..13ede525 100644 --- a/light-client/src/render/sprite.rs +++ b/light-client/src/render/sprite.rs @@ -10,10 +10,10 @@ pub struct Sprite { impl Sprite { pub fn new(src: Rect, anchor: Vec2, elevation: f32) -> Self { let relative_dst = FRect::new( - anchor.x - (src.w as f32) / 32. / 2., - anchor.y - (src.h as f32) / 24., + -anchor.x - (src.w as f32) / 32. / 2., + -anchor.y - (src.h as f32) / 24., (src.w as f32) / 32., - (src.h as f32) / 32., + (src.h as f32) / 24., ); Self { z_offset: -relative_dst.h + anchor.y - elevation, @@ -21,8 +21,8 @@ impl Sprite { relative_dst, } } - pub fn new_tile(src: Rect) { - Self::new(src, Vec2::new(0.5, 1.0), 0.); + pub fn new_tile(src: Rect) -> Self { + Self::new(src, Vec2::new(0.5, 1.0), 0.) } pub fn at(&self, pos: Vec2) -> SpriteDraw { SpriteDraw { @@ -38,6 +38,7 @@ impl Sprite { } } +#[derive(Debug, Clone, Copy)] pub struct SpriteDraw { pub z_order: i32, pub src: Rect, |