Skip to content
Snippets Groups Projects
Commit 0e3ce1dc authored by Rendre's avatar Rendre
Browse files

Change camera position and added hide hud feature

parent 9dff62c0
No related branches found
No related tags found
1 merge request!79Finishing touches to game
......@@ -18,6 +18,7 @@ import engine.terrain.Selector;
import engine.terrain.Terrain;
import engine.terrain.ZoneTile;
import engine.textures.TextureAttribute;
import engine.tools.Keyboard;
import engine.tools.Mouse;
import engine.tools.MousePicker;
import engine.world.WorldGrid;
......@@ -33,10 +34,12 @@ import model.zone.Zone;
import model.zone.ZoneStatistics;
import org.joml.Vector2f;
import org.joml.Vector3f;
import org.lwjgl.glfw.GLFW;
import view.MoneyStatistic;
import view.ViewModel;
import java.util.List;
import static org.lwjgl.glfw.GLFW.*;
public class Handler implements ICallBack {
......@@ -69,6 +72,7 @@ public class Handler implements ICallBack {
private boolean moneyTab = false;
private boolean isGameOver = false;
private boolean exitGame = false;
private boolean HUD = true;
public Handler(String saveFile) {
......@@ -79,7 +83,7 @@ public class Handler implements ICallBack {
this.worldGrid = new WorldGrid(loader, new TextureAttribute(loader.loadTexture("zones/grass")));
this.selector = new Selector(Terrain.getSize(), Terrain.getSize(),0, 0, loader, new TextureAttribute(loader.loadTexture("selector")));
this.camera = new Camera(new Vector3f(0, 100, 0));
this.camera = new Camera(new Vector3f(Terrain.getSize() * worldGrid.getWorldSize() / 2, 40, Terrain.getSize() * worldGrid.getWorldSize() / 2 + 5));
this.light = new Light(new Vector3f(50, 1000, 50), new Vector3f(1, 1, 1));
this.guiRenderer = new GuiRenderer(loader);
......@@ -216,7 +220,7 @@ public class Handler implements ICallBack {
}
}
}
viewModel.taxIncDecButtons(moneyTab,gameModel);
viewModel.taxIncDecButtons(moneyTab,gameModel);
if(paused)
......@@ -232,20 +236,22 @@ public class Handler implements ICallBack {
}
}
if (Keyboard.isClicked(GLFW_KEY_F3)) {
if (HUD) {HUD = false;}
else {HUD = true;}
}
Mouse.update();
processAllAssets();
masterRenderer.render(selector, camera, light);
guiRenderer.render(viewModel.getButtons(), viewModel.getTabs());
if (HUD) {
guiRenderer.render(viewModel.getButtons(), viewModel.getTabs());
TextMaster.render();
}
TextMaster.render();
loader.clearTextVaos();
if (paused == false) {
timer += DisplayManager.getFrameTimeSeconds();
}
......
......@@ -31,7 +31,7 @@ public class Camera extends Entity{
*/
public Camera(Vector3f position) {
super(position);
super.increaseRotation(0, 225, 0);
super.increaseRotation(0, -90, 0);
}
/**
......
......@@ -2,6 +2,9 @@ package engine.tools;
import org.lwjgl.glfw.GLFWKeyCallback;
import java.util.ArrayList;
import java.util.List;
import static org.lwjgl.glfw.GLFW.GLFW_PRESS;
import static org.lwjgl.glfw.GLFW.GLFW_RELEASE;
......@@ -11,6 +14,8 @@ import static org.lwjgl.glfw.GLFW.GLFW_RELEASE;
*/
public class Keyboard extends GLFWKeyCallback {
private static boolean[] keys = new boolean[65536];
private static boolean[] keys2 = new boolean[65536];
private static List<Integer> pressed = new ArrayList<Integer>();
@Override
public void invoke(long window, int key, int scancode, int action, int mods) {
......@@ -18,7 +23,7 @@ public class Keyboard extends GLFWKeyCallback {
return;
}
keys[key] = action != GLFW_RELEASE;
keys2[key] = action == GLFW_RELEASE;
}
/**
......@@ -30,6 +35,12 @@ public class Keyboard extends GLFWKeyCallback {
return keys[keycode];
}
public static boolean isClicked(int keycode) {
if (keys2[keycode]) {
keys2[keycode] =false;
return true;
}
return false;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment