From 1ded694712cae00e1ba7f2401ccbd747d43c2fc4 Mon Sep 17 00:00:00 2001 From: MrDev023 Date: Wed, 22 Jul 2015 09:58:00 +0200 Subject: [PATCH] p --- VBO/.classpath | 1 + VBO/src/mrdev023/game/MainMenu.java | 51 +++++++++++++++++-- VBO/src/mrdev023/game/SoloGame.java | 1 + VBO/src/mrdev023/gameEngine/GameEngine.java | 3 ++ VBO/src/mrdev023/math/Color4f.java | 4 +- VBO/src/mrdev023/math/Vector2f.java | 4 +- .../mrdev023/rendering/DisplayManager.java | 5 +- VBO/src/mrdev023/world/World.java | 9 ---- VBO/src/mrdev023/world/chunk/Chunk.java | 1 - 9 files changed, 62 insertions(+), 17 deletions(-) diff --git a/VBO/.classpath b/VBO/.classpath index 0d779fa..c0a1358 100644 --- a/VBO/.classpath +++ b/VBO/.classpath @@ -7,5 +7,6 @@ + diff --git a/VBO/src/mrdev023/game/MainMenu.java b/VBO/src/mrdev023/game/MainMenu.java index e3b46da..804d508 100644 --- a/VBO/src/mrdev023/game/MainMenu.java +++ b/VBO/src/mrdev023/game/MainMenu.java @@ -1,24 +1,61 @@ package mrdev023.game; +import static org.lwjgl.opengl.GL11.*; + +import java.util.*; + import mrdev023.game.gamestate.*; +import mrdev023.gameEngine.*; +import mrdev023.math.*; +import mrdev023.rendering.gui.*; +import mrdev023.rendering.gui.action.*; import mrdev023.world.*; +import org.lwjgl.input.*; +import org.lwjgl.opengl.*; + public class MainMenu implements GameInterface{ + + public ArrayList guiList = new ArrayList(); + + public MainMenu(){ + GUI button = new ButtonGUI("SOLO",Display.getDisplayMode().getWidth()/2 - 100,Display.getDisplayMode().getHeight()/2 - 80,200,60); + button.setAction(new Action() { + public void manageAction(int action) { + if(action == GUI.CLICKED)GameEngine.changeGameState(GameState.SOLO_GAME); + } + + public void hover(Vector2f position) {} + }); + guiList.add(button); + guiList.add(new LabelGUI("Test Voxel v0.1", Display.getDisplayMode().getWidth()/2 - 100, Display.getDisplayMode().getHeight()/2 - 300, 200, 100)); + } public void render() { } public void update() { + for(GUI gui : guiList){ + gui.updateAction(); + } + } public void renderGUI() { - + glColor3f(0,0,0); + glPointSize(5); + glBegin(GL_POINTS); + glVertex2f(Mouse.getX(),Display.getDisplayMode().getHeight() - Mouse.getY()); + glEnd(); + for(GUI gui : guiList){ + gui.render(); + } } public void destroyGameState() { - + } public World getWorld() { @@ -30,7 +67,15 @@ public class MainMenu implements GameInterface{ } public void updateKeyboard() { - + while(Keyboard.next()){ + if(Keyboard.getEventKeyState()){ + if(Keyboard.getEventKey() == Keyboard.KEY_ESCAPE){ + GameEngine.setRunning(false); + } + }else{ + + } + } } } diff --git a/VBO/src/mrdev023/game/SoloGame.java b/VBO/src/mrdev023/game/SoloGame.java index 16e548d..c14031e 100644 --- a/VBO/src/mrdev023/game/SoloGame.java +++ b/VBO/src/mrdev023/game/SoloGame.java @@ -65,6 +65,7 @@ public class SoloGame extends Game implements GameInterface{ float s = 1; glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); glDisable(GL_CULL_FACE); + glColor3f(1, 1, 1); glLineWidth(2); glBegin(GL_QUADS); glVertex3f(x,y,z); diff --git a/VBO/src/mrdev023/gameEngine/GameEngine.java b/VBO/src/mrdev023/gameEngine/GameEngine.java index 09d64f2..cbbfc09 100644 --- a/VBO/src/mrdev023/gameEngine/GameEngine.java +++ b/VBO/src/mrdev023/gameEngine/GameEngine.java @@ -5,6 +5,7 @@ import java.util.concurrent.*; import org.lwjgl.input.*; import org.lwjgl.opengl.*; +import mrdev023.audio.*; import mrdev023.game.*; import mrdev023.game.gamestate.*; import mrdev023.main.*; @@ -32,6 +33,7 @@ public class GameEngine { Display.setDisplayMode(new DisplayMode(width, height)); Display.setResizable(true); Display.create(); + AudioManager.create(); Camera.initCamera(); Mouse.setGrabbed(true); gameState = GameState.MAIN_MENU; @@ -104,6 +106,7 @@ public class GameEngine { public static void destroy(){ gameState.destroyGameState(); + AudioManager.destroy(); Display.destroy(); } diff --git a/VBO/src/mrdev023/math/Color4f.java b/VBO/src/mrdev023/math/Color4f.java index e9fac7a..869d65f 100644 --- a/VBO/src/mrdev023/math/Color4f.java +++ b/VBO/src/mrdev023/math/Color4f.java @@ -100,6 +100,8 @@ public class Color4f { this.a = a; } - + public java.awt.Color toAwtColor(){ + return new java.awt.Color(r, g, g, a); + } } diff --git a/VBO/src/mrdev023/math/Vector2f.java b/VBO/src/mrdev023/math/Vector2f.java index dd882f2..94509fb 100644 --- a/VBO/src/mrdev023/math/Vector2f.java +++ b/VBO/src/mrdev023/math/Vector2f.java @@ -30,6 +30,8 @@ public class Vector2f { return new Vector2f(x,y); } - + public String toString(){ + return x + " " + y; + } } \ No newline at end of file diff --git a/VBO/src/mrdev023/rendering/DisplayManager.java b/VBO/src/mrdev023/rendering/DisplayManager.java index 7f582c0..3c7fb65 100644 --- a/VBO/src/mrdev023/rendering/DisplayManager.java +++ b/VBO/src/mrdev023/rendering/DisplayManager.java @@ -4,6 +4,7 @@ import static org.lwjgl.util.glu.GLU.*; import mrdev023.gameEngine.*; import mrdev023.update.*; +import org.lwjgl.input.*; import org.lwjgl.opengl.*; import org.lwjgl.util.glu.*; @@ -47,10 +48,10 @@ public class DisplayManager { * @Info Definie le mode d'affichage pour le rendu en 2d */ public static void preRender2D(){ + glDisable(GL_CULL_FACE); glMatrixMode(GL_PROJECTION); glLoadIdentity(); - GLU.gluOrtho2D(0, Display.getDisplayMode().getWidth(), Display - .getDisplayMode().getHeight(), 0); + glOrtho(0,Display.getDisplayMode().getWidth(),Display.getDisplayMode().getHeight(),0,-1,1); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); } diff --git a/VBO/src/mrdev023/world/World.java b/VBO/src/mrdev023/world/World.java index e4eee2d..affefe9 100644 --- a/VBO/src/mrdev023/world/World.java +++ b/VBO/src/mrdev023/world/World.java @@ -23,15 +23,6 @@ public abstract class World { this.seed= seed; this.octave = octave; this.amplitude = amplitude; - for(int x = 0;x < SIZE;x++){ - for(int y = 0;y < HEIGHT;y++){ - for(int z = 0;z < SIZE;z++){ - Chunk ch = new Chunk(x,y,z,this); - chunks.add(ch); - } - } - } - for(Chunk ch : chunks)ch.createChunk(this); } public static long updateWorldTime = 0; diff --git a/VBO/src/mrdev023/world/chunk/Chunk.java b/VBO/src/mrdev023/world/chunk/Chunk.java index 40a7cac..c031f9c 100644 --- a/VBO/src/mrdev023/world/chunk/Chunk.java +++ b/VBO/src/mrdev023/world/chunk/Chunk.java @@ -38,7 +38,6 @@ public class Chunk { public void createChunk(World world) { this.world = world; - Main.addThread(new Generate(this, world),"Create Chunk"); IsCurrentGenerate = true; }