diff --git a/.classpath b/.classpath
index cfd3392..324a40d 100644
--- a/.classpath
+++ b/.classpath
@@ -4,6 +4,9 @@
+
+
+
diff --git a/resources/texmap.old.png b/resources/texmap.old.png
new file mode 100644
index 0000000..90ac527
Binary files /dev/null and b/resources/texmap.old.png differ
diff --git a/resources/texmap.png b/resources/texmap.png
index 90ac527..8e10a00 100644
Binary files a/resources/texmap.png and b/resources/texmap.png differ
diff --git a/resources/texmap.xcf b/resources/texmap.xcf
index ae9c49c..2c1165e 100644
Binary files a/resources/texmap.xcf and b/resources/texmap.xcf differ
diff --git a/src/projectzombie/display/DisplayRenderUI.java b/src/projectzombie/display/DisplayRenderUI.java
index f4d6c15..02f1a61 100644
--- a/src/projectzombie/display/DisplayRenderUI.java
+++ b/src/projectzombie/display/DisplayRenderUI.java
@@ -154,7 +154,7 @@ public class DisplayRenderUI
GlHelpers.pushMatrix();
GlHelpers.translate2(i * 2 / aspect_ratio, 0.3);
player_item.item.render(new Vec2d(0, 0), new Vec2d(1.5, 1.5));
- GlHelpers.translate2(0.5 / aspect_ratio, -0.1);
+ GlHelpers.translate2(0, -0.1);
Text.render(Integer.toString(player_item.count), text_size);
GlHelpers.popMatrix();
}
@@ -167,7 +167,7 @@ public class DisplayRenderUI
if(!item_active.isEmpty())
{
GlHelpers.pushMatrix();
- GlHelpers.translate2(3.5, -7.25);
+ GlHelpers.translate2(3.2, -7.25);
Text.render(item_active.item.getName(item_active.meta), text_size);
GlHelpers.popMatrix();
}
diff --git a/src/projectzombie/display/DisplayWindow.java b/src/projectzombie/display/DisplayWindow.java
index 1783934..852f591 100644
--- a/src/projectzombie/display/DisplayWindow.java
+++ b/src/projectzombie/display/DisplayWindow.java
@@ -26,6 +26,7 @@ public class DisplayWindow implements IMainloopTask
private int width;
private int height;
private boolean fullscreen = true;
+ private boolean mouseVisibility_last = false;
public int getWidth() {
return this.width;
@@ -127,10 +128,13 @@ public class DisplayWindow implements IMainloopTask
}
public void setMouseVisibility(boolean status) {
- if(status) {
- GLFW.glfwSetInputMode(window, GLFW.GLFW_CURSOR, GLFW.GLFW_CURSOR_NORMAL);
- } else {
- GLFW.glfwSetInputMode(window, GLFW.GLFW_CURSOR, GLFW.GLFW_CURSOR_HIDDEN);
+ if(status != mouseVisibility_last) {
+ mouseVisibility_last = status;
+ if(status) {
+ GLFW.glfwSetInputMode(window, GLFW.GLFW_CURSOR, GLFW.GLFW_CURSOR_NORMAL);
+ } else {
+ GLFW.glfwSetInputMode(window, GLFW.GLFW_CURSOR, GLFW.GLFW_CURSOR_HIDDEN);
+ }
}
}
diff --git a/src/projectzombie/init/Textures.java b/src/projectzombie/init/Textures.java
index 20fb7e3..2c406d4 100644
--- a/src/projectzombie/init/Textures.java
+++ b/src/projectzombie/init/Textures.java
@@ -44,6 +44,9 @@ public class Textures
public static final TextureReference ITEM_GRAPPLING_HOOK = texmap.getTextureReference(18, 19, 2, 3);
public static final TextureReference ENTITY_GRAPPLING_HOOK = texmap.getTextureReference(17, 18, 0, 16);
+ public static final TextureReference BUTTON = texmap.getTextureReference(18, 26, 8, 9);
+ public static final TextureReference BUTTON_HOVER = texmap.getTextureReference(18, 26, 9, 10);
+
public static final AnimationReference ENTITY_BOSS_IDLE = new AnimationReference(50,
texmap.getTextureReference(20, 22, 0, 2),
texmap.getTextureReference(22, 24, 0, 2),
diff --git a/src/projectzombie/input/CursorPosCallback.java b/src/projectzombie/input/CursorPosCallback.java
index 91bc9ca..66c4e76 100644
--- a/src/projectzombie/input/CursorPosCallback.java
+++ b/src/projectzombie/input/CursorPosCallback.java
@@ -4,19 +4,19 @@ import org.lwjgl.glfw.GLFW;
import org.lwjgl.glfw.GLFWCursorPosCallbackI;
import projectzombie.Main;
+import projectzombie.util.math.vec.Vec2d;
public class CursorPosCallback implements GLFWCursorPosCallbackI
{
- private boolean keepMouse_last = true;
-
@Override
public void invoke(long window, double x, double y) {
- if(keepMouse_last != Main.menu.keepMouse) {
- Main.window.setMouseVisibility(!Main.menu.keepMouse);
- keepMouse_last = Main.menu.keepMouse;
- } if(!Main.menu.keepMouse) {
+ Main.menu.input.mousePos(new Vec2d(x, y));
+ Main.window.setMouseVisibility(!Main.menu.keepMouse);
+
+ if(!Main.menu.keepMouse) {
return;
}
+
int wx = Main.window.getWidth();
int wy = Main.window.getHeight();
x = x / wx - 0.5;
diff --git a/src/projectzombie/input/KeyCallback.java b/src/projectzombie/input/KeyCallback.java
index c22d1b2..b3ee5e7 100644
--- a/src/projectzombie/input/KeyCallback.java
+++ b/src/projectzombie/input/KeyCallback.java
@@ -35,6 +35,7 @@ public class KeyCallback implements GLFWKeyCallbackI, IMainloopTask
private boolean esc_last = false;
private boolean action_last = false;
private boolean fullscreen_last = false;
+ private boolean fireGun_last = false;
@Override
public void invoke(long window, int key, int scancode, int action, int mods)
@@ -165,8 +166,14 @@ public class KeyCallback implements GLFWKeyCallbackI, IMainloopTask
}
if(fireGun) {
+ fireGun_last = true;
input.fire(true);
}
+
+ else if(fireGun_last) {
+ fireGun_last = false;
+ input.fire(false);
+ }
}
}
diff --git a/src/projectzombie/input/types/Input.java b/src/projectzombie/input/types/Input.java
index 66ba60d..a4dfc13 100644
--- a/src/projectzombie/input/types/Input.java
+++ b/src/projectzombie/input/types/Input.java
@@ -1,5 +1,7 @@
package projectzombie.input.types;
+import projectzombie.util.math.vec.Vec2d;
+
public interface Input
{
public void move(boolean state, double angle);
@@ -11,4 +13,5 @@ public interface Input
public void pause(boolean state);
public void hotbarGoto(boolean state, int pos);
public void hotbarShift(boolean state, int amount);
+ public void mousePos(Vec2d pos);
}
diff --git a/src/projectzombie/input/types/InputDeath.java b/src/projectzombie/input/types/InputDeath.java
index 811d7c6..f20168e 100644
--- a/src/projectzombie/input/types/InputDeath.java
+++ b/src/projectzombie/input/types/InputDeath.java
@@ -1,51 +1,12 @@
package projectzombie.input.types;
-import projectzombie.Main;
-import projectzombie.menu.Menu;
-import projectzombie.menu.MenuDeath;
+import projectzombie.menu.gui.GUI;
-public class InputDeath implements Input
+public class InputDeath extends InputGUI
{
- @Override
- public void move(boolean state, double angle) {
- }
-
- @Override
- public void fire(boolean state) {
- Menu menu = Main.menu;
- if(menu instanceof MenuDeath) {
- MenuDeath menu_d = (MenuDeath) menu;
- menu_d.resetting = state;
- }
- }
-
- @Override
- public void activateTile(boolean state) {
- }
-
- @Override
- public void camera(boolean state, double amount) {
- }
-
- @Override
- public void itemAction(boolean state) {
- }
-
- @Override
- public void itemDrop(boolean state) {
- }
-
- @Override
- public void pause(boolean state) {
- }
-
- @Override
- public void hotbarGoto(boolean state, int pos) {
- }
-
- @Override
- public void hotbarShift(boolean state, int amount) {
+ public InputDeath(GUI gui) {
+ super(gui);
}
}
diff --git a/src/projectzombie/input/types/InputGUI.java b/src/projectzombie/input/types/InputGUI.java
new file mode 100644
index 0000000..75c326b
--- /dev/null
+++ b/src/projectzombie/input/types/InputGUI.java
@@ -0,0 +1,58 @@
+package projectzombie.input.types;
+
+import projectzombie.menu.gui.GUI;
+import projectzombie.util.math.vec.Vec2d;
+
+public class InputGUI implements Input
+{
+ private GUI gui;
+ private boolean gunStateLast = false;
+
+ public InputGUI(GUI gui) {
+ this.gui = gui;
+ }
+
+ @Override
+ public void move(boolean state, double angle) {
+ this.gui.onMove(angle);
+ }
+
+ @Override
+ public void fire(boolean state) {
+ if(state) {
+ gunStateLast = true;
+ }
+
+ else if(gunStateLast) {
+ gunStateLast = false;
+ gui.onMouseClick();
+ }
+ }
+
+ @Override
+ public void activateTile(boolean state) {}
+
+ @Override
+ public void camera(boolean state, double amount) {}
+
+ @Override
+ public void itemAction(boolean state) {}
+
+ @Override
+ public void itemDrop(boolean state) {}
+
+ @Override
+ public void pause(boolean state) {}
+
+ @Override
+ public void hotbarGoto(boolean state, int pos) {}
+
+ @Override
+ public void hotbarShift(boolean state, int amount) {}
+
+ @Override
+ public void mousePos(Vec2d pos) {
+ this.gui.updateMousePos(pos);
+ }
+
+}
diff --git a/src/projectzombie/input/types/InputGame.java b/src/projectzombie/input/types/InputGame.java
index 29752e8..11f815f 100644
--- a/src/projectzombie/input/types/InputGame.java
+++ b/src/projectzombie/input/types/InputGame.java
@@ -3,6 +3,7 @@ package projectzombie.input.types;
import projectzombie.Main;
import projectzombie.menu.MenuGamePause;
import projectzombie.util.math.MathHelpers;
+import projectzombie.util.math.vec.Vec2d;
public class InputGame implements Input
{
@@ -66,4 +67,8 @@ public class InputGame implements Input
Main.player.inventory_hand = MathHelpers.mod(Main.player.inventory_hand, 6);
}
+ @Override
+ public void mousePos(Vec2d pos) {
+ }
+
}
diff --git a/src/projectzombie/input/types/InputGamePause.java b/src/projectzombie/input/types/InputGamePause.java
index 0a97774..cc4c980 100644
--- a/src/projectzombie/input/types/InputGamePause.java
+++ b/src/projectzombie/input/types/InputGamePause.java
@@ -1,54 +1,21 @@
package projectzombie.input.types;
import projectzombie.Main;
-import projectzombie.menu.Menu;
import projectzombie.menu.MenuGame;
-import projectzombie.menu.MenuGamePause;
+import projectzombie.menu.gui.GUI;
-public class InputGamePause implements Input
+public class InputGamePause extends InputGUI
{
- @Override
- public void move(boolean state, double angle) {
- }
-
- @Override
- public void fire(boolean state) {
- Menu menu = Main.menu;
- if(menu instanceof MenuGamePause) {
- MenuGamePause menu_gp = (MenuGamePause) menu;
- menu_gp.resetting = state;
- }
- }
-
- @Override
- public void activateTile(boolean state) {
- }
-
- @Override
- public void camera(boolean state, double amount) {
- }
-
- @Override
- public void itemAction(boolean state) {
- }
-
- @Override
- public void itemDrop(boolean state) {
+ public InputGamePause(GUI gui) {
+ super(gui);
}
@Override
public void pause(boolean state) {
+ super.pause(state);
Main.menu = new MenuGame();
Main.game_paused = false;
}
- @Override
- public void hotbarGoto(boolean state, int pos) {
- }
-
- @Override
- public void hotbarShift(boolean state, int amount) {
- }
-
}
diff --git a/src/projectzombie/input/types/InputMenu.java b/src/projectzombie/input/types/InputMenu.java
deleted file mode 100644
index 2f64e84..0000000
--- a/src/projectzombie/input/types/InputMenu.java
+++ /dev/null
@@ -1,60 +0,0 @@
-package projectzombie.input.types;
-
-public class InputMenu implements Input
-{
-
- @Override
- public void move(boolean state, double angle) {
- // TODO
-
- }
-
- @Override
- public void fire(boolean state) {
- // TODO Auto-generated method stub
-
- }
-
- @Override
- public void activateTile(boolean state) {
- // TODO Auto-generated method stub
-
- }
-
- @Override
- public void camera(boolean state, double amount) {
- // TODO Auto-generated method stub
-
- }
-
- @Override
- public void itemAction(boolean state) {
- // TODO Auto-generated method stub
-
- }
-
- @Override
- public void itemDrop(boolean state) {
- // TODO Auto-generated method stub
-
- }
-
- @Override
- public void pause(boolean state) {
- // TODO Auto-generated method stub
-
- }
-
- @Override
- public void hotbarGoto(boolean state, int pos) {
- // TODO Auto-generated method stub
-
- }
-
- @Override
- public void hotbarShift(boolean state, int amount) {
- // TODO Auto-generated method stub
-
- }
-
-}
diff --git a/src/projectzombie/menu/MenuDeath.java b/src/projectzombie/menu/MenuDeath.java
index b1cd393..01fcc4f 100644
--- a/src/projectzombie/menu/MenuDeath.java
+++ b/src/projectzombie/menu/MenuDeath.java
@@ -1,21 +1,25 @@
package projectzombie.menu;
import projectzombie.input.types.InputDeath;
+import projectzombie.menu.gui.GUI;
+import projectzombie.menu.gui.components.ButtonRespawn;
import projectzombie.text.Text;
import projectzombie.util.gl.GlHelpers;
import projectzombie.util.math.vec.Vec2d;
public class MenuDeath extends Menu
{
-
- public boolean resetting = false;
- private MenuRespawn menu_restart = new MenuRespawn();
+ private GUI gui;
public MenuDeath() {
this.doGameloop = false;
this.doGameRender = true;
this.keepMouse = false;
- this.input = new InputDeath();
+
+ this.gui = new GUI();
+ this.input = new InputDeath(this.gui);
+
+ gui.add(new ButtonRespawn());
}
@Override
@@ -35,18 +39,11 @@ public class MenuDeath extends Menu
// Render some text to say the player is dead
GlHelpers.pushMatrix();
- GlHelpers.translate2(0, 4);
+ GlHelpers.translate2(0, 2.4);
Text.renderCenter("You Died", new Vec2d(1, 1));
GlHelpers.popMatrix();
- this.menu_restart.render();
- }
-
- @Override
- public void update() {
- super.update();
- this.menu_restart.update(resetting);
- resetting = false;
+ gui.render();
}
}
diff --git a/src/projectzombie/menu/MenuGamePause.java b/src/projectzombie/menu/MenuGamePause.java
index c410c24..cc47388 100644
--- a/src/projectzombie/menu/MenuGamePause.java
+++ b/src/projectzombie/menu/MenuGamePause.java
@@ -1,20 +1,25 @@
package projectzombie.menu;
import projectzombie.input.types.InputGamePause;
+import projectzombie.menu.gui.GUI;
+import projectzombie.menu.gui.components.ButtonRespawn;
import projectzombie.text.Text;
import projectzombie.util.gl.GlHelpers;
import projectzombie.util.math.vec.Vec2d;
public class MenuGamePause extends Menu
{
- public boolean resetting;
- private MenuRespawn menu_restart = new MenuRespawn();
+ private GUI gui;
public MenuGamePause() {
this.doGameloop = false;
this.doGameRender = true;
this.keepMouse = false;
- this.input = new InputGamePause();
+
+ this.gui = new GUI();
+ this.input = new InputGamePause(this.gui);
+
+ gui.add(new ButtonRespawn());
}
@Override
@@ -34,18 +39,10 @@ public class MenuGamePause extends Menu
// Render some text to say the game is paused
GlHelpers.pushMatrix();
- GlHelpers.translate2(0, 4);
+ GlHelpers.translate2(0, 2.4);
Text.renderCenter("Game Paused", new Vec2d(1, 1));
GlHelpers.popMatrix();
- menu_restart.render();
+ gui.render();
}
-
- @Override
- public void update() {
- super.update();
- menu_restart.update(resetting);
- resetting = false;
- }
-
}
diff --git a/src/projectzombie/menu/MenuMain.java b/src/projectzombie/menu/MenuMain.java
index 13af0e1..f5a4d5c 100644
--- a/src/projectzombie/menu/MenuMain.java
+++ b/src/projectzombie/menu/MenuMain.java
@@ -1,18 +1,23 @@
package projectzombie.menu;
-import projectzombie.input.types.InputMenu;
+import projectzombie.input.types.InputGUI;
+import projectzombie.menu.gui.GUI;
public class MenuMain extends Menu
{
+ private GUI gui;
+
public MenuMain() {
this.doGameloop = false;
this.doGameRender = false;
- this.input = new InputMenu();
+
+ this.gui = new GUI();
+ this.input = new InputGUI(gui);
}
@Override
public void render() {
-
+ this.gui.render();
}
}
diff --git a/src/projectzombie/menu/gui/Button.java b/src/projectzombie/menu/gui/Button.java
new file mode 100644
index 0000000..f1fe28a
--- /dev/null
+++ b/src/projectzombie/menu/gui/Button.java
@@ -0,0 +1,86 @@
+package projectzombie.menu.gui;
+
+import projectzombie.Main;
+import projectzombie.init.Textures;
+import projectzombie.text.Text;
+import projectzombie.util.gl.GlHelpers;
+import projectzombie.util.gl.texture.TextureReference;
+import projectzombie.util.math.vec.Vec2d;
+
+public class Button implements GUIComponent
+{
+ private Vec2d pos;
+ private String text;
+
+ private static Vec2d textSize = new Vec2d(0.5, 0.5);
+
+ public Button(Vec2d pos, String text) {
+ this.pos = pos;
+ this.text = text;
+ }
+
+ @Override
+ public void render(Vec2d mousePos) {
+ GlHelpers.pushMatrix();
+ GlHelpers.translate2(pos.x, pos.y);
+
+ double m = 2.5;
+ double w = textSize.x * m * 8 / 2;
+ double h = textSize.x * m / 2;
+
+ TextureReference tex;
+ boolean mouseHover = this.checkMouseHover(mousePos);
+ if(mouseHover) {
+ tex = Textures.BUTTON_HOVER;
+ } else {
+ tex = Textures.BUTTON;
+ }
+
+ GlHelpers.color4(1, 1, 1, 1);
+ GlHelpers.begin();
+ {
+ tex.texCoord(0, 0); GlHelpers.vertex2(-w, -h);
+ tex.texCoord(1, 0); GlHelpers.vertex2( w, -h);
+ tex.texCoord(1, 1); GlHelpers.vertex2( w, h);
+ tex.texCoord(0, 1); GlHelpers.vertex2(-w, h);
+ }
+ GlHelpers.end();
+
+ GlHelpers.translate2(
+ (-textSize.x * text.length() / 2)/GlHelpers.getAspectRatio(),
+ -textSize.y / 2
+ );
+
+ if(mouseHover) {
+ GlHelpers.color3(0.8, 0.8, 0.8);
+ } else {
+ GlHelpers.color3(0.68, 0.68, 0.68);
+ }
+ Text.render(text, textSize);
+
+ GlHelpers.popMatrix();
+ }
+
+ @Override
+ public boolean checkMouseHover(Vec2d pos) {
+
+ double m = 2.5;
+ double w = textSize.x * m * 8 / 2 / GlHelpers.getAspectRatio();
+ double h = textSize.x * m / 2;
+
+ double mx = pos.x / Main.window.getWidth() * 20 - 10;
+ double my = pos.y / Main.window.getHeight() * 20 - 10;
+
+ return (
+ mx > -w - this.pos.x &&
+ mx < w - this.pos.x &&
+ my > -h - this.pos.y &&
+ my < h - this.pos.y
+ );
+ }
+
+ @Override
+ public void onMouseClick(Vec2d pos) {
+ }
+
+}
diff --git a/src/projectzombie/menu/gui/GUI.java b/src/projectzombie/menu/gui/GUI.java
new file mode 100644
index 0000000..72596c0
--- /dev/null
+++ b/src/projectzombie/menu/gui/GUI.java
@@ -0,0 +1,54 @@
+package projectzombie.menu.gui;
+
+import java.util.ArrayList;
+
+import projectzombie.util.math.vec.Vec2d;
+
+public class GUI implements GUIComponent, GUIContainer
+{
+ private ArrayList components = new ArrayList();
+ private Vec2d mousePos = new Vec2d(0, 0);
+
+ @Override
+ public void render(Vec2d mousePos) {
+ for(GUIComponent c : components) {
+ c.render(mousePos);
+ }
+ }
+
+ public void render() {
+ this.render(mousePos);
+ }
+
+ @Override
+ public void add(GUIComponent c) {
+ components.add(c);
+ }
+
+ public void updateMousePos(Vec2d pos) {
+ this.mousePos = pos;
+ }
+
+ public void onMove(double angle) {
+
+ }
+
+ @Override
+ public boolean checkMouseHover(Vec2d pos) {
+ return false;
+ }
+
+ @Override
+ public void onMouseClick(Vec2d pos) {
+ for(GUIComponent c : components) {
+ if(c.checkMouseHover(mousePos)) {
+ c.onMouseClick(mousePos);
+ }
+ }
+ }
+
+ public void onMouseClick() {
+ this.onMouseClick(mousePos);
+ }
+
+}
diff --git a/src/projectzombie/menu/gui/GUIComponent.java b/src/projectzombie/menu/gui/GUIComponent.java
new file mode 100644
index 0000000..6dded62
--- /dev/null
+++ b/src/projectzombie/menu/gui/GUIComponent.java
@@ -0,0 +1,11 @@
+package projectzombie.menu.gui;
+
+import projectzombie.util.math.vec.Vec2d;
+
+public interface GUIComponent
+{
+ public void render(Vec2d mousePos);
+
+ public boolean checkMouseHover(Vec2d pos);
+ public void onMouseClick(Vec2d pos);
+}
diff --git a/src/projectzombie/menu/gui/GUIContainer.java b/src/projectzombie/menu/gui/GUIContainer.java
new file mode 100644
index 0000000..a091f56
--- /dev/null
+++ b/src/projectzombie/menu/gui/GUIContainer.java
@@ -0,0 +1,6 @@
+package projectzombie.menu.gui;
+
+public interface GUIContainer
+{
+ public void add(GUIComponent c);
+}
diff --git a/src/projectzombie/menu/gui/components/ButtonRespawn.java b/src/projectzombie/menu/gui/components/ButtonRespawn.java
new file mode 100644
index 0000000..625126f
--- /dev/null
+++ b/src/projectzombie/menu/gui/components/ButtonRespawn.java
@@ -0,0 +1,35 @@
+package projectzombie.menu.gui.components;
+
+import java.util.Random;
+
+import projectzombie.Main;
+import projectzombie.display.bossbar.BossBars;
+import projectzombie.entity.player.EntityPlayer;
+import projectzombie.init.Layers;
+import projectzombie.menu.MenuGame;
+import projectzombie.menu.gui.Button;
+import projectzombie.time.GameTimer;
+import projectzombie.util.math.vec.Vec2d;
+
+public class ButtonRespawn extends Button
+{
+ private static final Random rand = new Random();
+
+ public ButtonRespawn() {
+ super(new Vec2d(0, -2), "Respawn");
+ }
+
+ @Override
+ public void onMouseClick(Vec2d pos) {
+ super.onMouseClick(pos);
+
+ // Reset the world and the player
+ Layers.init(rand.nextLong());
+ Main.player = new EntityPlayer();
+ Main.menu = new MenuGame();
+ Main.game_paused = false;
+ GameTimer.resetTime();
+ BossBars.clear();
+ }
+
+}
diff --git a/src/projectzombie/text/Text.java b/src/projectzombie/text/Text.java
index 2242d48..d4d1771 100644
--- a/src/projectzombie/text/Text.java
+++ b/src/projectzombie/text/Text.java
@@ -95,7 +95,7 @@ public class Text
int w = Main.window.getWidth();
int h = Main.window.getHeight();
double aspect_ratio = ((double)w) / ((double)h);
- GlHelpers.translate2(0 - ((text.length() - 2) * size.x / 2 / aspect_ratio), 0);
+ GlHelpers.translate2(0 - (text.length() * size.x / 2 / aspect_ratio), 0);
Text.render(text, size);
}
@@ -204,10 +204,10 @@ public class Text
if(l != null)
{
// Render the character
- l.texCoord(0, 1); GlHelpers.vertex2(sy*(i-1), 0);
- l.texCoord(0, 0); GlHelpers.vertex2(sy*(i-1), sx);
- l.texCoord(1, 0); GlHelpers.vertex2(sy*i, sx);
- l.texCoord(1, 1); GlHelpers.vertex2(sy*i, 0);
+ l.texCoord(0, 1); GlHelpers.vertex2(sy*i, 0 );
+ l.texCoord(0, 0); GlHelpers.vertex2(sy*i, sx);
+ l.texCoord(1, 0); GlHelpers.vertex2(sy*(i+1), sx);
+ l.texCoord(1, 1); GlHelpers.vertex2(sy*(i+1), 0 );
}
}
diff --git a/src/projectzombie/util/gl/GlHelpers.java b/src/projectzombie/util/gl/GlHelpers.java
index 1df8890..f0c49f4 100644
--- a/src/projectzombie/util/gl/GlHelpers.java
+++ b/src/projectzombie/util/gl/GlHelpers.java
@@ -25,6 +25,13 @@ public class GlHelpers
{
private static int MATRIX_COUNT = 0;
+ public static double getAspectRatio() {
+ int w = Main.window.getWidth();
+ int h = Main.window.getHeight();
+ double aspect_ratio = ((double)w) / ((double)h);
+ return aspect_ratio;
+ }
+
public static void checkMatrixCount() {
if(MATRIX_COUNT != 0) {
MATRIX_COUNT = 0;
@@ -45,9 +52,7 @@ public class GlHelpers
}
public static void vertex2(double x, double y) {
- int w = Main.window.getWidth();
- int h = Main.window.getHeight();
- double aspect_ratio = ((double)w) / ((double)h);
+ double aspect_ratio = getAspectRatio();
glVertex2d(x/10/aspect_ratio, y/10);
}