diff options
author | metamuffin <metamuffin@disroot.org> | 2024-08-14 22:58:09 +0200 |
---|---|---|
committer | metamuffin <metamuffin@disroot.org> | 2024-08-14 22:58:09 +0200 |
commit | 16bdd6964705a9995d1ccd9451264db59a4e8879 (patch) | |
tree | 2c4ccab3eed4f2d77bda70dbc26a80f879c9167e /pixel-client/src/render | |
parent | 66cfc6f5a6352d65f1b198547baaebdd2366b8a4 (diff) | |
download | hurrycurry-16bdd6964705a9995d1ccd9451264db59a4e8879.tar hurrycurry-16bdd6964705a9995d1ccd9451264db59a4e8879.tar.bz2 hurrycurry-16bdd6964705a9995d1ccd9451264db59a4e8879.tar.zst |
pc: add item bubbles
Diffstat (limited to 'pixel-client/src/render')
-rw-r--r-- | pixel-client/src/render/misc.rs | 4 | ||||
-rw-r--r-- | pixel-client/src/render/sprite.rs | 14 |
2 files changed, 16 insertions, 2 deletions
diff --git a/pixel-client/src/render/misc.rs b/pixel-client/src/render/misc.rs index 7a631154..77dc52b0 100644 --- a/pixel-client/src/render/misc.rs +++ b/pixel-client/src/render/misc.rs @@ -25,7 +25,7 @@ pub struct MiscTextures { pub interact_target: Sprite, pub solid: Rect, pub clouds: Rect, - pub itembubble: Rect, + pub itembubble: Sprite, } impl MiscTextures { @@ -40,7 +40,7 @@ impl MiscTextures { ), solid: *layout.get("solid+a").unwrap(), clouds: *layout.get("clouds+a").unwrap(), - itembubble: *layout.get("itembubble+a").unwrap(), + itembubble: Sprite::new(*layout.get("itembubble+a").unwrap(), Vec2::Y * -1., 1.), } } } diff --git a/pixel-client/src/render/sprite.rs b/pixel-client/src/render/sprite.rs index 292a99ab..7d0a195a 100644 --- a/pixel-client/src/render/sprite.rs +++ b/pixel-client/src/render/sprite.rs @@ -89,6 +89,20 @@ impl SpriteDraw { self.tint[2] = b; self } + pub fn elevate(mut self, offset: f32) -> SpriteDraw { + self.z_order += (offset * 24.) as i32; + self.dst.set_y(self.dst.y() - offset); + self + } + pub fn scale(mut self, factor: f32) -> SpriteDraw { + self.dst + .set_x(self.dst.x() + self.dst.width() * 0.5 * (1. - factor)); + self.dst + .set_y(self.dst.y() + self.dst.height() * 0.5 * (1. - factor)); + self.dst.set_width(self.dst.width() * factor); + self.dst.set_height(self.dst.height() * factor); + self + } } impl Ord for SpriteDraw { |