Fixed checkMouseHover reliability issues
This commit is contained in:
parent
b2f26fd838
commit
7ca1d80e6a
Binary file not shown.
|
|
@ -5,7 +5,6 @@ import java.util.Random;
|
||||||
import mainloop.manager.MainloopManager;
|
import mainloop.manager.MainloopManager;
|
||||||
import projectzombie.audio.AudioEngine;
|
import projectzombie.audio.AudioEngine;
|
||||||
import projectzombie.audio.AudioSources;
|
import projectzombie.audio.AudioSources;
|
||||||
import projectzombie.cheats.Cheats;
|
|
||||||
import projectzombie.display.DisplayStatsEventHandler;
|
import projectzombie.display.DisplayStatsEventHandler;
|
||||||
import projectzombie.display.DisplayWindow;
|
import projectzombie.display.DisplayWindow;
|
||||||
import projectzombie.display.bossbar.BossBars;
|
import projectzombie.display.bossbar.BossBars;
|
||||||
|
|
@ -20,6 +19,9 @@ import projectzombie.input.KeyCallback;
|
||||||
import projectzombie.mainloop.MainloopEventHandler;
|
import projectzombie.mainloop.MainloopEventHandler;
|
||||||
import projectzombie.menu.Menu;
|
import projectzombie.menu.Menu;
|
||||||
import projectzombie.menu.MenuMain;
|
import projectzombie.menu.MenuMain;
|
||||||
|
import projectzombie.settings.Cheats;
|
||||||
|
import projectzombie.settings.Environment;
|
||||||
|
import projectzombie.settings.Settings;
|
||||||
import projectzombie.tiles.LightLevelNoise;
|
import projectzombie.tiles.LightLevelNoise;
|
||||||
import projectzombie.time.GameTimer;
|
import projectzombie.time.GameTimer;
|
||||||
import projectzombie.time.NoSleep;
|
import projectzombie.time.NoSleep;
|
||||||
|
|
@ -49,8 +51,10 @@ public class Main
|
||||||
|
|
||||||
public static void main(String[] args)
|
public static void main(String[] args)
|
||||||
{
|
{
|
||||||
// Initialize the cheats
|
// Initialize cheats, settings, and environment
|
||||||
|
Environment.init(args);
|
||||||
Cheats.init(args);
|
Cheats.init(args);
|
||||||
|
Settings.init();
|
||||||
|
|
||||||
// Load the resources
|
// Load the resources
|
||||||
Resources.loadResources();
|
Resources.loadResources();
|
||||||
|
|
|
||||||
|
|
@ -1,15 +1,6 @@
|
||||||
package projectzombie.display;
|
package projectzombie.display;
|
||||||
|
|
||||||
import static org.lwjgl.opengl.GL11.GL_COLOR_BUFFER_BIT;
|
import static org.lwjgl.opengl.GL33.*;
|
||||||
import static org.lwjgl.opengl.GL11.GL_DEPTH_BUFFER_BIT;
|
|
||||||
import static org.lwjgl.opengl.GL11.GL_MODELVIEW;
|
|
||||||
import static org.lwjgl.opengl.GL11.GL_ONE_MINUS_SRC_ALPHA;
|
|
||||||
import static org.lwjgl.opengl.GL11.GL_SRC_ALPHA;
|
|
||||||
import static org.lwjgl.opengl.GL11.glBlendFunc;
|
|
||||||
import static org.lwjgl.opengl.GL11.glClear;
|
|
||||||
import static org.lwjgl.opengl.GL11.glLoadMatrixf;
|
|
||||||
import static org.lwjgl.opengl.GL11.glMatrixMode;
|
|
||||||
import static org.lwjgl.opengl.GL11.glViewport;
|
|
||||||
|
|
||||||
import org.joml.Matrix4f;
|
import org.joml.Matrix4f;
|
||||||
import org.lwjgl.opengl.GL;
|
import org.lwjgl.opengl.GL;
|
||||||
|
|
@ -23,6 +14,7 @@ import projectzombie.init.Textures;
|
||||||
import projectzombie.util.gl.GlHelpers;
|
import projectzombie.util.gl.GlHelpers;
|
||||||
import projectzombie.util.math.vec.Vec2d;
|
import projectzombie.util.math.vec.Vec2d;
|
||||||
import projectzombie.util.math.vec.Vec3d;
|
import projectzombie.util.math.vec.Vec3d;
|
||||||
|
import projectzombie.world.chunk.Chunk;
|
||||||
|
|
||||||
public class DisplayRender
|
public class DisplayRender
|
||||||
{
|
{
|
||||||
|
|
@ -82,7 +74,10 @@ public class DisplayRender
|
||||||
0.0f, 1.0f, 0.0f);
|
0.0f, 1.0f, 0.0f);
|
||||||
|
|
||||||
EntityPlayer player = Main.player;
|
EntityPlayer player = Main.player;
|
||||||
Camera camera = new Camera(new Vec3d(player.pos.x, player.pos.y, 0), new Vec2d(player.angle, 45), 10, 1);
|
Camera camera = new Camera(
|
||||||
|
new Vec3d(player.pos.x, player.pos.y, 0),
|
||||||
|
new Vec2d(player.angle, 45),
|
||||||
|
10, Chunk.RENDER_DISTANCE);
|
||||||
Camera.camera = camera;
|
Camera.camera = camera;
|
||||||
|
|
||||||
//GlHelpers.translate(0, 0, -5);
|
//GlHelpers.translate(0, 0, -5);
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,8 @@ import projectzombie.world.layer.Layer;
|
||||||
|
|
||||||
public class LightingManager
|
public class LightingManager
|
||||||
{
|
{
|
||||||
|
public static int lightingMode = 0;
|
||||||
|
|
||||||
public static void update()
|
public static void update()
|
||||||
{
|
{
|
||||||
if(!ChunkEventHandler.loaded) return;
|
if(!ChunkEventHandler.loaded) return;
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,6 @@ package projectzombie.entity.player;
|
||||||
|
|
||||||
import mainloop.task.IMainloopTask;
|
import mainloop.task.IMainloopTask;
|
||||||
import projectzombie.Main;
|
import projectzombie.Main;
|
||||||
import projectzombie.cheats.Cheats;
|
|
||||||
import projectzombie.display.Camera;
|
import projectzombie.display.Camera;
|
||||||
import projectzombie.entity.Entity;
|
import projectzombie.entity.Entity;
|
||||||
import projectzombie.entity.EntityAlive;
|
import projectzombie.entity.EntityAlive;
|
||||||
|
|
@ -14,6 +13,7 @@ import projectzombie.entity.EntityVertical;
|
||||||
import projectzombie.init.Textures;
|
import projectzombie.init.Textures;
|
||||||
import projectzombie.inventory.Inventory;
|
import projectzombie.inventory.Inventory;
|
||||||
import projectzombie.menu.MenuDeath;
|
import projectzombie.menu.MenuDeath;
|
||||||
|
import projectzombie.settings.Cheats;
|
||||||
import projectzombie.util.gl.GlHelpers;
|
import projectzombie.util.gl.GlHelpers;
|
||||||
import projectzombie.util.gl.texture.TextureReference;
|
import projectzombie.util.gl.texture.TextureReference;
|
||||||
import projectzombie.util.math.ItemStack;
|
import projectzombie.util.math.ItemStack;
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,7 @@ class GameInput
|
||||||
static boolean hotbar_r = false;
|
static boolean hotbar_r = false;
|
||||||
|
|
||||||
static boolean startButton_last = false;
|
static boolean startButton_last = false;
|
||||||
|
static boolean backButton_last = false;
|
||||||
|
|
||||||
static boolean moveLeft = false;
|
static boolean moveLeft = false;
|
||||||
static boolean moveRight = false;
|
static boolean moveRight = false;
|
||||||
|
|
|
||||||
|
|
@ -1,15 +1,6 @@
|
||||||
package projectzombie.input;
|
package projectzombie.input;
|
||||||
|
|
||||||
import static projectzombie.input.GameInput.activateItem_last;
|
import static projectzombie.input.GameInput.*;
|
||||||
import static projectzombie.input.GameInput.activateTile_last;
|
|
||||||
import static projectzombie.input.GameInput.dropItem_last;
|
|
||||||
import static projectzombie.input.GameInput.fireGun;
|
|
||||||
import static projectzombie.input.GameInput.hotbar_l;
|
|
||||||
import static projectzombie.input.GameInput.hotbar_r;
|
|
||||||
import static projectzombie.input.GameInput.moveDown;
|
|
||||||
import static projectzombie.input.GameInput.moveUp;
|
|
||||||
import static projectzombie.input.GameInput.move_last;
|
|
||||||
import static projectzombie.input.GameInput.startButton_last;
|
|
||||||
|
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
import java.nio.FloatBuffer;
|
import java.nio.FloatBuffer;
|
||||||
|
|
@ -20,6 +11,7 @@ import org.lwjgl.glfw.GLFWJoystickCallbackI;
|
||||||
|
|
||||||
import mainloop.task.IMainloopTask;
|
import mainloop.task.IMainloopTask;
|
||||||
import projectzombie.Main;
|
import projectzombie.Main;
|
||||||
|
import projectzombie.display.DisplayWindow;
|
||||||
import projectzombie.input.types.Input;
|
import projectzombie.input.types.Input;
|
||||||
|
|
||||||
public class JoystickCallback implements GLFWJoystickCallbackI, IMainloopTask
|
public class JoystickCallback implements GLFWJoystickCallbackI, IMainloopTask
|
||||||
|
|
@ -158,6 +150,8 @@ public class JoystickCallback implements GLFWJoystickCallbackI, IMainloopTask
|
||||||
double angle = Math.toDegrees(Math.atan2(left_y, left_x)) + 90;
|
double angle = Math.toDegrees(Math.atan2(left_y, left_x)) + 90;
|
||||||
input.move(true, angle);
|
input.move(true, angle);
|
||||||
move_last = true;
|
move_last = true;
|
||||||
|
|
||||||
|
Main.window.setMouseVisibility(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set the players moving to false
|
// Set the players moving to false
|
||||||
|
|
@ -169,15 +163,18 @@ public class JoystickCallback implements GLFWJoystickCallbackI, IMainloopTask
|
||||||
// Is the right x axis stick moved into a position (camera stick)
|
// Is the right x axis stick moved into a position (camera stick)
|
||||||
if(right_x > 0.3 || right_x < -0.3) {
|
if(right_x > 0.3 || right_x < -0.3) {
|
||||||
input.camera(true, right_x);
|
input.camera(true, right_x);
|
||||||
|
Main.window.setMouseVisibility(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Gun trigger
|
// Gun trigger
|
||||||
if(right_trigger > 0.3 && !fireGun) {
|
if(right_trigger > 0.3 && !fireGun) {
|
||||||
input.fire(true);
|
input.fire(true);
|
||||||
|
Main.window.setMouseVisibility(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Item trigger
|
// Item trigger
|
||||||
if(left_trigger > 0.3) {
|
if(left_trigger > 0.3) {
|
||||||
|
Main.window.setMouseVisibility(false);
|
||||||
if(!activateItem_last)
|
if(!activateItem_last)
|
||||||
{
|
{
|
||||||
activateItem_last = true;
|
activateItem_last = true;
|
||||||
|
|
@ -190,6 +187,7 @@ public class JoystickCallback implements GLFWJoystickCallbackI, IMainloopTask
|
||||||
}
|
}
|
||||||
|
|
||||||
if(shoulder_left) {
|
if(shoulder_left) {
|
||||||
|
Main.window.setMouseVisibility(false);
|
||||||
if(!hotbar_l) {
|
if(!hotbar_l) {
|
||||||
hotbar_l = true;
|
hotbar_l = true;
|
||||||
input.hotbarShift(true, -1);
|
input.hotbarShift(true, -1);
|
||||||
|
|
@ -201,6 +199,7 @@ public class JoystickCallback implements GLFWJoystickCallbackI, IMainloopTask
|
||||||
}
|
}
|
||||||
|
|
||||||
if(shoulder_right) {
|
if(shoulder_right) {
|
||||||
|
Main.window.setMouseVisibility(false);
|
||||||
if(!hotbar_r) {
|
if(!hotbar_r) {
|
||||||
hotbar_r = true;
|
hotbar_r = true;
|
||||||
input.hotbarShift(true, 1);
|
input.hotbarShift(true, 1);
|
||||||
|
|
@ -213,6 +212,7 @@ public class JoystickCallback implements GLFWJoystickCallbackI, IMainloopTask
|
||||||
|
|
||||||
// Activate tile
|
// Activate tile
|
||||||
if(button_x) {
|
if(button_x) {
|
||||||
|
Main.window.setMouseVisibility(false);
|
||||||
if(!activateTile_last) {
|
if(!activateTile_last) {
|
||||||
input.activateTile(true);
|
input.activateTile(true);
|
||||||
activateTile_last = true;
|
activateTile_last = true;
|
||||||
|
|
@ -225,6 +225,7 @@ public class JoystickCallback implements GLFWJoystickCallbackI, IMainloopTask
|
||||||
|
|
||||||
// Drop item
|
// Drop item
|
||||||
if(button_b) {
|
if(button_b) {
|
||||||
|
Main.window.setMouseVisibility(false);
|
||||||
if(!dropItem_last) {
|
if(!dropItem_last) {
|
||||||
input.itemDrop(true);
|
input.itemDrop(true);
|
||||||
dropItem_last = true;
|
dropItem_last = true;
|
||||||
|
|
@ -235,8 +236,21 @@ public class JoystickCallback implements GLFWJoystickCallbackI, IMainloopTask
|
||||||
dropItem_last = false;
|
dropItem_last = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Pause and unpause the game
|
// Back button
|
||||||
|
if(button_b) {
|
||||||
|
if(!backButton_last) {
|
||||||
|
input.back(true);
|
||||||
|
backButton_last = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
else if(backButton_last) {
|
||||||
|
backButton_last = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Pause the game
|
||||||
if(button_start) {
|
if(button_start) {
|
||||||
|
Main.window.setMouseVisibility(false);
|
||||||
if(!startButton_last) {
|
if(!startButton_last) {
|
||||||
startButton_last = true;
|
startButton_last = true;
|
||||||
input.pause(true);
|
input.pause(true);
|
||||||
|
|
|
||||||
|
|
@ -1,26 +1,7 @@
|
||||||
package projectzombie.input;
|
package projectzombie.input;
|
||||||
|
|
||||||
import static org.lwjgl.glfw.GLFW.GLFW_KEY_1;
|
import static org.lwjgl.glfw.GLFW.*;
|
||||||
import static org.lwjgl.glfw.GLFW.GLFW_KEY_2;
|
import static projectzombie.input.GameInput.*;
|
||||||
import static org.lwjgl.glfw.GLFW.GLFW_KEY_3;
|
|
||||||
import static org.lwjgl.glfw.GLFW.GLFW_KEY_4;
|
|
||||||
import static org.lwjgl.glfw.GLFW.GLFW_KEY_5;
|
|
||||||
import static org.lwjgl.glfw.GLFW.GLFW_KEY_6;
|
|
||||||
import static org.lwjgl.glfw.GLFW.GLFW_KEY_A;
|
|
||||||
import static org.lwjgl.glfw.GLFW.GLFW_KEY_D;
|
|
||||||
import static org.lwjgl.glfw.GLFW.GLFW_KEY_E;
|
|
||||||
import static org.lwjgl.glfw.GLFW.GLFW_KEY_ESCAPE;
|
|
||||||
import static org.lwjgl.glfw.GLFW.GLFW_KEY_F11;
|
|
||||||
import static org.lwjgl.glfw.GLFW.GLFW_KEY_Q;
|
|
||||||
import static org.lwjgl.glfw.GLFW.GLFW_KEY_S;
|
|
||||||
import static org.lwjgl.glfw.GLFW.GLFW_KEY_W;
|
|
||||||
import static org.lwjgl.glfw.GLFW.GLFW_RELEASE;
|
|
||||||
import static projectzombie.input.GameInput.fireGun;
|
|
||||||
import static projectzombie.input.GameInput.moveDown;
|
|
||||||
import static projectzombie.input.GameInput.moveLeft;
|
|
||||||
import static projectzombie.input.GameInput.moveRight;
|
|
||||||
import static projectzombie.input.GameInput.moveUp;
|
|
||||||
import static projectzombie.input.GameInput.move_last;
|
|
||||||
|
|
||||||
import org.lwjgl.glfw.GLFWKeyCallbackI;
|
import org.lwjgl.glfw.GLFWKeyCallbackI;
|
||||||
|
|
||||||
|
|
@ -112,6 +93,16 @@ public class KeyCallback implements GLFWKeyCallbackI, IMainloopTask
|
||||||
else if(esc_last) {
|
else if(esc_last) {
|
||||||
esc_last = false;
|
esc_last = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(pressed) {
|
||||||
|
if(!backButton_last) {
|
||||||
|
backButton_last = true;
|
||||||
|
input.back(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if(backButton_last) {
|
||||||
|
backButton_last = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(key == GLFW_KEY_F11) {
|
if(key == GLFW_KEY_F11) {
|
||||||
|
|
|
||||||
|
|
@ -14,4 +14,5 @@ public interface Input
|
||||||
public void hotbarGoto(boolean state, int pos);
|
public void hotbarGoto(boolean state, int pos);
|
||||||
public void hotbarShift(boolean state, int amount);
|
public void hotbarShift(boolean state, int amount);
|
||||||
public void mousePos(Vec2d pos);
|
public void mousePos(Vec2d pos);
|
||||||
|
public void back(boolean state);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,12 +0,0 @@
|
||||||
package projectzombie.input.types;
|
|
||||||
|
|
||||||
import projectzombie.menu.gui.GUI;
|
|
||||||
|
|
||||||
public class InputDeath extends InputGUI
|
|
||||||
{
|
|
||||||
|
|
||||||
public InputDeath(GUI gui) {
|
|
||||||
super(gui);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -55,4 +55,9 @@ public class InputGUI implements Input
|
||||||
this.gui.updateMousePos(pos);
|
this.gui.updateMousePos(pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void back(boolean state) {
|
||||||
|
gui.onBack();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -71,4 +71,8 @@ public class InputGame implements Input
|
||||||
public void mousePos(Vec2d pos) {
|
public void mousePos(Vec2d pos) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void back(boolean state) {
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,21 +0,0 @@
|
||||||
package projectzombie.input.types;
|
|
||||||
|
|
||||||
import projectzombie.Main;
|
|
||||||
import projectzombie.menu.MenuGame;
|
|
||||||
import projectzombie.menu.gui.GUI;
|
|
||||||
|
|
||||||
public class InputGamePause extends InputGUI
|
|
||||||
{
|
|
||||||
|
|
||||||
public InputGamePause(GUI gui) {
|
|
||||||
super(gui);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void pause(boolean state) {
|
|
||||||
super.pause(state);
|
|
||||||
Main.menu = new MenuGame();
|
|
||||||
Main.game_paused = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,8 +1,9 @@
|
||||||
package projectzombie.menu;
|
package projectzombie.menu;
|
||||||
|
|
||||||
import projectzombie.input.types.InputDeath;
|
import projectzombie.input.types.InputGUI;
|
||||||
import projectzombie.menu.gui.GUI;
|
import projectzombie.menu.gui.GUI;
|
||||||
import projectzombie.menu.gui.components.LabelRespawn;
|
import projectzombie.menu.gui.components.ButtonGroupPause;
|
||||||
|
import projectzombie.menu.gui.components.LabelPause;
|
||||||
import projectzombie.menu.gui.components.OverlayBackground;
|
import projectzombie.menu.gui.components.OverlayBackground;
|
||||||
|
|
||||||
public class MenuDeath extends Menu
|
public class MenuDeath extends Menu
|
||||||
|
|
@ -15,10 +16,11 @@ public class MenuDeath extends Menu
|
||||||
this.keepMouse = false;
|
this.keepMouse = false;
|
||||||
|
|
||||||
this.gui = new GUI();
|
this.gui = new GUI();
|
||||||
this.input = new InputDeath(this.gui);
|
this.input = new InputGUI(this.gui);
|
||||||
|
|
||||||
gui.add(new OverlayBackground());
|
gui.add(new OverlayBackground());
|
||||||
gui.add(new LabelRespawn("You Died"));
|
gui.add(new LabelPause("You Died!"));
|
||||||
|
gui.add(new ButtonGroupPause());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,13 @@
|
||||||
package projectzombie.menu;
|
package projectzombie.menu;
|
||||||
|
|
||||||
import projectzombie.Main;
|
import projectzombie.Main;
|
||||||
import projectzombie.input.types.InputGamePause;
|
import projectzombie.input.types.InputGUI;
|
||||||
import projectzombie.menu.gui.ButtonGroup;
|
import projectzombie.menu.gui.ButtonGroup;
|
||||||
import projectzombie.menu.gui.GUI;
|
import projectzombie.menu.gui.GUI;
|
||||||
import projectzombie.menu.gui.components.ButtonBasic;
|
import projectzombie.menu.gui.components.ButtonBasic;
|
||||||
import projectzombie.menu.gui.components.LabelRespawn;
|
import projectzombie.menu.gui.components.ButtonGroupPause;
|
||||||
|
import projectzombie.menu.gui.components.GUIBackToMenu;
|
||||||
|
import projectzombie.menu.gui.components.LabelPause;
|
||||||
import projectzombie.menu.gui.components.OverlayBackground;
|
import projectzombie.menu.gui.components.OverlayBackground;
|
||||||
import projectzombie.util.math.vec.Vec2d;
|
import projectzombie.util.math.vec.Vec2d;
|
||||||
|
|
||||||
|
|
@ -18,24 +20,12 @@ public class MenuGamePause extends Menu
|
||||||
this.doGameRender = true;
|
this.doGameRender = true;
|
||||||
this.keepMouse = false;
|
this.keepMouse = false;
|
||||||
|
|
||||||
this.gui = new GUI();
|
this.gui = new GUIBackToMenu(Main.menu);
|
||||||
this.input = new InputGamePause(this.gui);
|
this.input = new InputGUI(this.gui);
|
||||||
|
|
||||||
gui.add(new OverlayBackground());
|
gui.add(new OverlayBackground());
|
||||||
gui.add(new LabelRespawn("Game Paused"));
|
gui.add(new LabelPause("Game Paused"));
|
||||||
|
gui.add(new ButtonGroupPause());
|
||||||
ButtonGroup group = new ButtonGroup();
|
|
||||||
|
|
||||||
group.add(new ButtonBasic("Settings", button -> {
|
|
||||||
Main.menu = new MenuSettings(new MenuGamePause());
|
|
||||||
}));
|
|
||||||
|
|
||||||
group.add(new ButtonBasic("Quit", button -> {
|
|
||||||
Main.menu = new MenuMain();
|
|
||||||
}));
|
|
||||||
|
|
||||||
group.setPos(new Vec2d(0, -2));
|
|
||||||
gui.add(group);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -8,8 +8,10 @@ import projectzombie.menu.gui.GUI;
|
||||||
import projectzombie.menu.gui.Label;
|
import projectzombie.menu.gui.Label;
|
||||||
import projectzombie.menu.gui.components.ButtonBasic;
|
import projectzombie.menu.gui.components.ButtonBasic;
|
||||||
import projectzombie.menu.gui.components.ButtonSetting;
|
import projectzombie.menu.gui.components.ButtonSetting;
|
||||||
|
import projectzombie.menu.gui.components.GUIBackToMenu;
|
||||||
import projectzombie.menu.gui.components.OverlayBackground;
|
import projectzombie.menu.gui.components.OverlayBackground;
|
||||||
import projectzombie.util.math.vec.Vec2d;
|
import projectzombie.util.math.vec.Vec2d;
|
||||||
|
import projectzombie.world.chunk.Chunk;
|
||||||
|
|
||||||
public class MenuSettings extends Menu
|
public class MenuSettings extends Menu
|
||||||
{
|
{
|
||||||
|
|
@ -28,26 +30,40 @@ public class MenuSettings extends Menu
|
||||||
ButtonGroup group = new ButtonGroup();
|
ButtonGroup group = new ButtonGroup();
|
||||||
group.setPos(new Vec2d(-1, 4));
|
group.setPos(new Vec2d(-1, 4));
|
||||||
|
|
||||||
group.add(new ButtonSetting(DisplayRenderUI.showFPS ? "FPS: On" : "FPS: Off", button -> {
|
group.add(new ButtonSetting("FPS: " + (DisplayRenderUI.showFPS ? "On" : "Off"), button -> {
|
||||||
if(DisplayRenderUI.showFPS) {
|
|
||||||
button.setText("FPS: Off");
|
|
||||||
} else {
|
|
||||||
button.setText("FPS: On");
|
|
||||||
}
|
|
||||||
DisplayRenderUI.showFPS = !DisplayRenderUI.showFPS;
|
DisplayRenderUI.showFPS = !DisplayRenderUI.showFPS;
|
||||||
|
button.setText("FPS: " + (DisplayRenderUI.showFPS ? "On" : "Off"));
|
||||||
}));
|
}));
|
||||||
|
|
||||||
group.add(new ButtonSetting(DisplayRenderUI.showPos ? "Pos Indicator: On" : "Pos Indicator: Off",
|
group.add(new ButtonSetting("Pos Indicator: " + (DisplayRenderUI.showPos ? "On" : "Off"),
|
||||||
button -> {
|
button ->
|
||||||
if(DisplayRenderUI.showPos) {
|
{
|
||||||
button.setText("Pos Indicator: Off");
|
|
||||||
} else {
|
|
||||||
button.setText("Pos Indicator: On");
|
|
||||||
}
|
|
||||||
DisplayRenderUI.showPos = !DisplayRenderUI.showPos;
|
DisplayRenderUI.showPos = !DisplayRenderUI.showPos;
|
||||||
|
button.setText("Pos Indicator: " + (DisplayRenderUI.showPos ? "On" : "Off"));
|
||||||
}));
|
}));
|
||||||
|
|
||||||
gui = new GUI();
|
group.add(new ButtonSetting("Render Distance: "+Chunk.RENDER_DISTANCE, button -> {
|
||||||
|
Chunk.RENDER_DISTANCE += 1;
|
||||||
|
if(Chunk.RENDER_DISTANCE > 5) {
|
||||||
|
Chunk.RENDER_DISTANCE = 1;
|
||||||
|
}
|
||||||
|
button.setText("Render Distance: "+Chunk.RENDER_DISTANCE);
|
||||||
|
}));
|
||||||
|
|
||||||
|
/*group.add(new ButtonSetting("Dynamic Lighting: " + (LightingManager.lightingMode == 0 ? "Fast" : "Fancy"),
|
||||||
|
button ->
|
||||||
|
{
|
||||||
|
if(LightingManager.lightingMode == 0) {
|
||||||
|
LightingManager.lightingMode = 1;
|
||||||
|
|
||||||
|
} else {
|
||||||
|
LightingManager.lightingMode = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
button.setText("Dynamic Lighting: " + (LightingManager.lightingMode == 0 ? "Fast" : "Fancy"));
|
||||||
|
}));*/
|
||||||
|
|
||||||
|
gui = new GUIBackToMenu(menuOld);
|
||||||
input = new InputGUI(gui);
|
input = new InputGUI(gui);
|
||||||
|
|
||||||
if(doGameRender) {
|
if(doGameRender) {
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,7 @@ public class Button implements GUIComponent
|
||||||
GlHelpers.pushMatrix();
|
GlHelpers.pushMatrix();
|
||||||
GlHelpers.translate2(pos.x, pos.y);
|
GlHelpers.translate2(pos.x, pos.y);
|
||||||
|
|
||||||
double m = 2.5;
|
double m = 3;
|
||||||
double w = textSize.x * m * 8;
|
double w = textSize.x * m * 8;
|
||||||
double h = textSize.x * m / 2;
|
double h = textSize.x * m / 2;
|
||||||
|
|
||||||
|
|
@ -94,45 +94,43 @@ public class Button implements GUIComponent
|
||||||
@Override
|
@Override
|
||||||
public boolean checkMouseHover(Vec2d pos) {
|
public boolean checkMouseHover(Vec2d pos) {
|
||||||
|
|
||||||
double m = 2.5;
|
|
||||||
double w = textSize.x * m * 8 / GlHelpers.getAspectRatio();
|
|
||||||
double h = textSize.x * m / 2;
|
|
||||||
|
|
||||||
double mx = pos.x / Main.window.getWidth() * 20 - 10;
|
double mx = pos.x / Main.window.getWidth() * 20 - 10;
|
||||||
double my = pos.y / Main.window.getHeight() * 20 - 10;
|
double my = pos.y / Main.window.getHeight() * 20 - 10;
|
||||||
|
|
||||||
|
double m = 3;
|
||||||
|
double w = textSize.x * m * 8 / GlHelpers.getAspectRatio();
|
||||||
|
double h = textSize.x * m / 2;
|
||||||
|
|
||||||
|
double w1 = 0;
|
||||||
|
double w2 = 0;
|
||||||
|
|
||||||
if(alignment == Alignment.LEFT) {
|
if(alignment == Alignment.LEFT) {
|
||||||
return (
|
w1 = 0;
|
||||||
mx > -this.pos.x &&
|
w2 = w;
|
||||||
mx < w - this.pos.x &&
|
|
||||||
my > -h - this.pos.y &&
|
|
||||||
my < h - this.pos.y
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(alignment == Alignment.CENTRE) {
|
if(alignment == Alignment.CENTRE) {
|
||||||
return (
|
w1 = -w/2;
|
||||||
mx > -w/2 - this.pos.x &&
|
w2 = w/2;
|
||||||
mx < w/2 - this.pos.x &&
|
|
||||||
my > -h - this.pos.y &&
|
|
||||||
my < h - this.pos.y
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(alignment == Alignment.RIGHT) {
|
if(alignment == Alignment.RIGHT) {
|
||||||
return (
|
w1 = -w;
|
||||||
mx > -w - this.pos.x &&
|
w2 = 0;
|
||||||
mx < -this.pos.x &&
|
|
||||||
my > -h - this.pos.y &&
|
|
||||||
my < h - this.pos.y
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return (
|
||||||
|
mx > w1 + this.pos.x &&
|
||||||
|
mx < w2 + this.pos.x &&
|
||||||
|
my > -h - this.pos.y &&
|
||||||
|
my < h - this.pos.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onMouseClick(Vec2d pos) {
|
public void onMouseClick(Vec2d pos) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onBack() {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ import java.util.ArrayList;
|
||||||
|
|
||||||
import projectzombie.util.math.vec.Vec2d;
|
import projectzombie.util.math.vec.Vec2d;
|
||||||
|
|
||||||
public class ButtonGroup implements GUIComponent, GUIContainer
|
public class ButtonGroup implements GUIContainer
|
||||||
{
|
{
|
||||||
private ArrayList<Button> buttons = new ArrayList<Button>();
|
private ArrayList<Button> buttons = new ArrayList<Button>();
|
||||||
private Vec2d pos = new Vec2d(0, 0);
|
private Vec2d pos = new Vec2d(0, 0);
|
||||||
|
|
@ -14,7 +14,7 @@ public class ButtonGroup implements GUIComponent, GUIContainer
|
||||||
|
|
||||||
for(int i=0;i<buttons.size();i++) {
|
for(int i=0;i<buttons.size();i++) {
|
||||||
Button b = buttons.get(i);
|
Button b = buttons.get(i);
|
||||||
b.setPos(new Vec2d(pos.x, pos.y + Button.textSize.y * -i * 3));
|
b.setPos(new Vec2d(pos.x, pos.y + Button.textSize.y * -i * 3.6));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -53,4 +53,11 @@ public class ButtonGroup implements GUIComponent, GUIContainer
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onBack() {
|
||||||
|
for(Button b : buttons) {
|
||||||
|
b.onBack();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,9 +2,10 @@ package projectzombie.menu.gui;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
import projectzombie.menu.Menu;
|
||||||
import projectzombie.util.math.vec.Vec2d;
|
import projectzombie.util.math.vec.Vec2d;
|
||||||
|
|
||||||
public class GUI implements GUIComponent, GUIContainer
|
public class GUI implements GUIContainer
|
||||||
{
|
{
|
||||||
private ArrayList<GUIComponent> components = new ArrayList<GUIComponent>();
|
private ArrayList<GUIComponent> components = new ArrayList<GUIComponent>();
|
||||||
private Vec2d mousePos = new Vec2d(0, 0);
|
private Vec2d mousePos = new Vec2d(0, 0);
|
||||||
|
|
@ -51,4 +52,11 @@ public class GUI implements GUIComponent, GUIContainer
|
||||||
this.onMouseClick(mousePos);
|
this.onMouseClick(mousePos);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onBack() {
|
||||||
|
for(GUIComponent c : components) {
|
||||||
|
c.onBack();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,5 +7,7 @@ public interface GUIComponent
|
||||||
public void render(Vec2d mousePos);
|
public void render(Vec2d mousePos);
|
||||||
|
|
||||||
public boolean checkMouseHover(Vec2d pos);
|
public boolean checkMouseHover(Vec2d pos);
|
||||||
|
|
||||||
public void onMouseClick(Vec2d pos);
|
public void onMouseClick(Vec2d pos);
|
||||||
|
public void onBack();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
package projectzombie.menu.gui;
|
package projectzombie.menu.gui;
|
||||||
|
|
||||||
public interface GUIContainer
|
public interface GUIContainer extends GUIComponent
|
||||||
{
|
{
|
||||||
public void add(GUIComponent c);
|
public void add(GUIComponent c);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -58,4 +58,8 @@ public class Label implements GUIComponent
|
||||||
public void onMouseClick(Vec2d pos) {
|
public void onMouseClick(Vec2d pos) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onBack() {
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -40,4 +40,8 @@ public class Overlay implements GUIComponent
|
||||||
public void onMouseClick(Vec2d pos) {
|
public void onMouseClick(Vec2d pos) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onBack() {
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,26 @@
|
||||||
|
package projectzombie.menu.gui.components;
|
||||||
|
|
||||||
|
import projectzombie.Main;
|
||||||
|
import projectzombie.menu.Menu;
|
||||||
|
import projectzombie.menu.MenuGamePause;
|
||||||
|
import projectzombie.menu.MenuMain;
|
||||||
|
import projectzombie.menu.MenuSettings;
|
||||||
|
import projectzombie.menu.gui.ButtonGroup;
|
||||||
|
import projectzombie.util.math.vec.Vec2d;
|
||||||
|
|
||||||
|
public class ButtonGroupPause extends ButtonGroup
|
||||||
|
{
|
||||||
|
public ButtonGroupPause()
|
||||||
|
{
|
||||||
|
add(new ButtonBasic("Settings", button -> {
|
||||||
|
Main.menu.input.mousePos(new Vec2d(0, 0));
|
||||||
|
Main.menu = new MenuSettings(Main.menu);
|
||||||
|
}));
|
||||||
|
|
||||||
|
add(new ButtonBasic("Quit", button -> {
|
||||||
|
Main.menu = new MenuMain();
|
||||||
|
}));
|
||||||
|
|
||||||
|
setPos(new Vec2d(0, -2));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,6 +1,8 @@
|
||||||
package projectzombie.menu.gui.components;
|
package projectzombie.menu.gui.components;
|
||||||
|
|
||||||
import projectzombie.menu.gui.Alignment;
|
import projectzombie.menu.gui.Alignment;
|
||||||
|
import projectzombie.settings.Settings;
|
||||||
|
import projectzombie.util.math.vec.Vec2d;
|
||||||
|
|
||||||
public class ButtonSetting extends ButtonBasic
|
public class ButtonSetting extends ButtonBasic
|
||||||
{
|
{
|
||||||
|
|
@ -11,6 +13,11 @@ public class ButtonSetting extends ButtonBasic
|
||||||
this.setAlign(Alignment.RIGHT);
|
this.setAlign(Alignment.RIGHT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onMouseClick(Vec2d pos) {
|
||||||
|
super.onMouseClick(pos);
|
||||||
|
|
||||||
|
Settings.update();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,21 @@
|
||||||
|
package projectzombie.menu.gui.components;
|
||||||
|
|
||||||
|
import projectzombie.Main;
|
||||||
|
import projectzombie.menu.Menu;
|
||||||
|
import projectzombie.menu.gui.GUI;
|
||||||
|
|
||||||
|
public class GUIBackToMenu extends GUI
|
||||||
|
{
|
||||||
|
private Menu back;
|
||||||
|
|
||||||
|
public GUIBackToMenu(Menu back) {
|
||||||
|
this.back = back;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onBack() {
|
||||||
|
super.onBack();
|
||||||
|
|
||||||
|
Main.menu = back;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -4,9 +4,9 @@ import projectzombie.menu.gui.Label;
|
||||||
import projectzombie.util.math.vec.Vec2d;
|
import projectzombie.util.math.vec.Vec2d;
|
||||||
import projectzombie.util.math.vec.Vec3d;
|
import projectzombie.util.math.vec.Vec3d;
|
||||||
|
|
||||||
public class LabelRespawn extends Label
|
public class LabelPause extends Label
|
||||||
{
|
{
|
||||||
public LabelRespawn(String text) {
|
public LabelPause(String text) {
|
||||||
setText(text);
|
setText(text);
|
||||||
setPos(new Vec2d(0, 2.4));
|
setPos(new Vec2d(0, 2.4));
|
||||||
setSize(new Vec2d(1, 1));
|
setSize(new Vec2d(1, 1));
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
package projectzombie.cheats;
|
package projectzombie.settings;
|
||||||
|
|
||||||
public class Cheats
|
public class Cheats
|
||||||
{
|
{
|
||||||
|
|
@ -0,0 +1,20 @@
|
||||||
|
package projectzombie.settings;
|
||||||
|
|
||||||
|
public class Environment
|
||||||
|
{
|
||||||
|
public static String gdir = ".";
|
||||||
|
|
||||||
|
public static void init(String args[])
|
||||||
|
{
|
||||||
|
for(String arg : args)
|
||||||
|
{
|
||||||
|
// --gdir=<game directory>
|
||||||
|
if(arg.startsWith("--gdir")) {
|
||||||
|
String[] split = arg.split("=");
|
||||||
|
if(split.length == 2) {
|
||||||
|
gdir = split[1];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,60 @@
|
||||||
|
package projectzombie.settings;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
|
||||||
|
import bdf.classes.BdfClassManager;
|
||||||
|
import bdf.classes.IBdfClassManager;
|
||||||
|
import bdf.file.BdfFileManager;
|
||||||
|
import bdf.types.BdfNamedList;
|
||||||
|
import bdf.types.BdfObject;
|
||||||
|
import bdf.types.BdfTypes;
|
||||||
|
import projectzombie.display.DisplayRenderUI;
|
||||||
|
import projectzombie.world.chunk.Chunk;
|
||||||
|
|
||||||
|
public class Settings implements IBdfClassManager
|
||||||
|
{
|
||||||
|
public static final BdfClassManager SETTINGS = new BdfClassManager(new Settings());
|
||||||
|
private static BdfFileManager FILE_MANAGER;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void BdfClassLoad(BdfObject bdf) {
|
||||||
|
BdfNamedList nl = bdf.getNamedList();
|
||||||
|
|
||||||
|
if(nl.get("render_distance").getType() == BdfTypes.INTEGER) {
|
||||||
|
Chunk.RENDER_DISTANCE = nl.get("render_distance").getInteger();
|
||||||
|
} else {
|
||||||
|
Chunk.RENDER_DISTANCE = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(nl.get("show_fps").getType() == BdfTypes.BOOLEAN) {
|
||||||
|
DisplayRenderUI.showFPS = nl.get("show_fps").getBoolean();
|
||||||
|
} else {
|
||||||
|
DisplayRenderUI.showFPS = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(nl.get("show_pos").getType() == BdfTypes.BOOLEAN) {
|
||||||
|
DisplayRenderUI.showPos = nl.get("show_pos").getBoolean();
|
||||||
|
} else {
|
||||||
|
DisplayRenderUI.showPos = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void BdfClassSave(BdfObject bdf) {
|
||||||
|
BdfNamedList nl = bdf.getNamedList();
|
||||||
|
nl.set("render_distance", BdfObject.withInteger(Chunk.RENDER_DISTANCE));
|
||||||
|
nl.set("show_fps", BdfObject.withBoolean(DisplayRenderUI.showFPS));
|
||||||
|
nl.set("show_pos", BdfObject.withBoolean(DisplayRenderUI.showPos));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void init() {
|
||||||
|
FILE_MANAGER = new BdfFileManager(Environment.gdir + "/settings.bdf");
|
||||||
|
SETTINGS.load(FILE_MANAGER);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void update() {
|
||||||
|
SETTINGS.save(FILE_MANAGER);
|
||||||
|
FILE_MANAGER.saveDatabase();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -22,9 +22,11 @@ public class Chunk
|
||||||
public static final Range2i CHUNK_SIZE = new Range2i(16, 16);
|
public static final Range2i CHUNK_SIZE = new Range2i(16, 16);
|
||||||
public static final Chunk CHUNK_EMPTY = new ChunkEmpty();
|
public static final Chunk CHUNK_EMPTY = new ChunkEmpty();
|
||||||
public static final int CHUNK_INDEX = CHUNK_SIZE.mx * CHUNK_SIZE.my;
|
public static final int CHUNK_INDEX = CHUNK_SIZE.mx * CHUNK_SIZE.my;
|
||||||
public static final int SIMULATION_DISTANCE = 5;
|
|
||||||
public static final Random rand = new Random();
|
public static final Random rand = new Random();
|
||||||
|
|
||||||
|
public static int SIMULATION_DISTANCE = 5;
|
||||||
|
public static int RENDER_DISTANCE = 1;
|
||||||
|
|
||||||
private Tile tiles_back[] = new Tile[CHUNK_INDEX];
|
private Tile tiles_back[] = new Tile[CHUNK_INDEX];
|
||||||
private Tile tiles_front[] = new Tile[CHUNK_INDEX];
|
private Tile tiles_front[] = new Tile[CHUNK_INDEX];
|
||||||
private byte tiles_front_meta[] = new byte[CHUNK_INDEX];
|
private byte tiles_front_meta[] = new byte[CHUNK_INDEX];
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue