From 180aad05decc7eefa87e4e45d6747c48f40e5361 Mon Sep 17 00:00:00 2001 From: Tyler Murphy Date: Mon, 17 Apr 2023 12:12:01 -0400 Subject: save --- .../java/net/tylermurphy/Minecraft/UI/UIImage.java | 30 ++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100755 src/main/java/net/tylermurphy/Minecraft/UI/UIImage.java (limited to 'src/main/java/net/tylermurphy/Minecraft/UI/UIImage.java') diff --git a/src/main/java/net/tylermurphy/Minecraft/UI/UIImage.java b/src/main/java/net/tylermurphy/Minecraft/UI/UIImage.java new file mode 100755 index 0000000..7e772ab --- /dev/null +++ b/src/main/java/net/tylermurphy/Minecraft/UI/UIImage.java @@ -0,0 +1,30 @@ +package net.tylermurphy.Minecraft.UI; + +import org.joml.Vector2f; + +import net.tylermurphy.Minecraft.Render.Data.Display; + +public class UIImage extends UIComponent { + + private int texture; + + public void setTexture(int texture) { + this.texture = texture; + } + + public int getTexture() { + return texture; + } + + public boolean clicked() { + Vector2f pos = Display.getCursorPos(); + float x1 = super.getConvertedPosition().x*Display.getWidth(); + float y1 = super.getConvertedPosition().y*Display.getHeight(); + float x2 = super.getConvertedPosition().x*Display.getWidth()+super.getConvertedSize().x*Display.getWidth(); + float y2 = super.getConvertedPosition().y*Display.getHeight()+super.getConvertedSize().y*Display.getHeight(); + if(pos.x >= x1 && pos.x <= x2 && pos.y >= y1 && pos.y <= y2) + return true; + return false; + } + +} -- cgit v1.2.3-freya