Skip to content
This repository has been archived by the owner on Oct 9, 2019. It is now read-only.

Commit

Permalink
Build-146: Removed NitroNet, New World Selection Screen (WIP)
Browse files Browse the repository at this point in the history
  • Loading branch information
Guerra24 committed Jan 11, 2016
1 parent 168e41a commit 4e00e8c
Show file tree
Hide file tree
Showing 30 changed files with 249 additions and 245 deletions.
4 changes: 2 additions & 2 deletions assets/game/settings.conf
@@ -1,5 +1,5 @@
#Voxel Settings
#Fri Jan 08 16:51:45 CST 2016
#Mon Jan 11 11:22:46 CST 2016
UPS=30
VSYNC=false
useMotionBlur=false
Expand All @@ -10,4 +10,4 @@ useVolumetricLight=false
TESTXMOD=Hello Voxel
useDOF=false
FPS=30
useShadows=true
useShadows=false
File renamed without changes.
Binary file modified assets/mods/XMod.jar
Binary file not shown.
3 changes: 2 additions & 1 deletion build.gradle
Expand Up @@ -13,6 +13,7 @@ jar {
include("*net/**")
include("*org/**")
include("assets/**")
include("log4j.properties")

manifest {
attributes 'Voxel-Branch': 'Develop',
Expand Down Expand Up @@ -50,7 +51,7 @@ dependencies {
compile 'org.lwjgl:lwjgl-platform:3.0.0-SNAPSHOT:natives-windows'
compile 'org.lwjgl:lwjgl-platform:3.0.0-SNAPSHOT:natives-linux'
compile 'org.lwjgl:lwjgl-platform:3.0.0-SNAPSHOT:natives-osx'
compile fileTree(dir: "libs", includes: ["*.jar"])
compile 'io.netty:netty-all:5.0.0.Alpha2'
}

sourceSets {
Expand Down
Binary file removed libs/NitroNet.jar
Binary file not shown.
Expand Up @@ -30,8 +30,8 @@

import net.guerra24.voxel.client.api.mod.MoltenAPIInitPhase;
import net.guerra24.voxel.client.api.mod.MoltenAPIMod;
import net.guerra24.voxel.client.core.GameSettings;
import net.guerra24.voxel.client.core.VoxelVariables;
import net.guerra24.voxel.client.resources.GameResources;
import net.guerra24.voxel.client.util.Logger;

/**
Expand All @@ -45,10 +45,10 @@ public class ModInitialization {
private ModLoader modLoader;
private MoltenAPI moltenAPI;

public ModInitialization(GameSettings gameSettings) {
public ModInitialization(GameResources gm) {
modLoader = new ModLoader();
modLoader.loadMods();
moltenAPI = new MoltenAPI(gameSettings);
moltenAPI = new MoltenAPI(gm);
}

/**
Expand Down
32 changes: 22 additions & 10 deletions src/main/java/net/guerra24/voxel/client/api/MoltenAPI.java
Expand Up @@ -24,26 +24,38 @@

package net.guerra24.voxel.client.api;

import net.guerra24.voxel.client.core.GameSettings;
import net.guerra24.voxel.client.world.entities.GameEntity;
import com.badlogic.ashley.core.Entity;

import net.guerra24.voxel.client.resources.GameResources;
import net.guerra24.voxel.client.world.block.Block;
import net.guerra24.voxel.client.world.block.IBlock;

public class MoltenAPI {

private GameSettings gameSettings;
private GameResources gm;

public MoltenAPI(GameSettings gameSettings) {
this.gameSettings = gameSettings;
public MoltenAPI(GameResources gm) {
this.gm = gm;
}

public void registetMob(GameEntity mob) {
public void registetEntity(Entity mob) {
gm.getPhysicsEngine().addEntity(mob);
}

public void registerSaveData(String key, String value) {
gameSettings.registerValue(key, value);
public void removeEntity(Entity entity) {
gm.getPhysicsEngine().removeEntity(entity);
}

public void registerBlock(IBlock block) {
Block.registerBlock(block);
}

public String getSaveData(String key){
return gameSettings.getValue(key);
public void registerSaveData(String key, String value) {
gm.getGameSettings().registerValue(key, value);
}

public String getSaveData(String key) {
return gm.getGameSettings().getValue(key);
}

}
Expand Up @@ -26,9 +26,10 @@

import net.guerra24.voxel.client.core.states.GameSPState;
import net.guerra24.voxel.client.core.states.InPauseState;
import net.guerra24.voxel.client.core.states.LoadingState;
import net.guerra24.voxel.client.core.states.LoadingSPState;
import net.guerra24.voxel.client.core.states.MainMenuState;
import net.guerra24.voxel.client.core.states.OptionsState;
import net.guerra24.voxel.client.core.states.WorldSelectionState;
import net.guerra24.voxel.client.graphics.opengl.Display;
import net.guerra24.voxel.client.input.Keyboard;
import net.guerra24.voxel.client.resources.Loader;
Expand All @@ -49,7 +50,7 @@ public class GlobalStates {

public enum GameState {
GAME_SP(new GameSPState()), MAINMENU(new MainMenuState()), IN_PAUSE(new InPauseState()), LOADING_WORLD(
new LoadingState()), OPTIONS(new OptionsState());
new LoadingSPState()), OPTIONS(new OptionsState()), WORLD_SELECTION(new WorldSelectionState());

GameState(State state) {
this.state = state;
Expand Down
28 changes: 13 additions & 15 deletions src/main/java/net/guerra24/voxel/client/core/State.java
Expand Up @@ -30,20 +30,18 @@
* @author danirod
* @category Kernel
*/
public abstract class State {

private int id;

public State(int id) {
this.id = id;
}

public abstract void update(Voxel voxel, GlobalStates states, float delta);

public abstract void render(Voxel voxel, GlobalStates states, float delta);

public int getId() {
return id;
}
public interface State {

/**
*
* This method is called every time in the game loop, it applies update
*
* @param voxel
* @param states
* @param delta
*/
public void update(Voxel voxel, GlobalStates states, float delta);

public void render(Voxel voxel, GlobalStates states, float alpha);

}
17 changes: 4 additions & 13 deletions src/main/java/net/guerra24/voxel/client/core/Voxel.java
Expand Up @@ -38,7 +38,6 @@
import net.guerra24.voxel.client.graphics.TextMasterRenderer;
import net.guerra24.voxel.client.graphics.opengl.Display;
import net.guerra24.voxel.client.input.Mouse;
import net.guerra24.voxel.client.network.DedicatedClient;
import net.guerra24.voxel.client.resources.GameResources;
import net.guerra24.voxel.client.util.Logger;
import net.guerra24.voxel.client.world.InfinityWorld;
Expand All @@ -63,7 +62,6 @@ public class Voxel {
private WorldsHandler worldsHandler;
private Display display;
private ModInitialization api;
private DedicatedClient client;

/**
* Constructor of the Kernel, Initializes the Game and starts the loop
Expand Down Expand Up @@ -96,7 +94,7 @@ public void preInit() {
if (Bootstrap.getPlatform() == Bootstrap.Platform.MACOSX) {
VoxelVariables.runningOnMac = true;
}
api = new ModInitialization(gameResources.getGameSettings());
api = new ModInitialization(gameResources);
try {
api.preInit();
} catch (VersionException e) {
Expand All @@ -119,11 +117,6 @@ private void init() {
Logger.log("Initializing Threads");
gameResources.getRenderer().prepare();

/*
* new Thread(new Runnable() { public void run() {
* Thread.currentThread().setName("Voxel-Client"); client = new
* DedicatedClient(gameResources); } }).start();
*/
try {
api.init();
} catch (VersionException e) {
Expand Down Expand Up @@ -161,6 +154,7 @@ public void mainLoop() {
float delta = 0;
float accumulator = 0f;
float interval = 1f / VoxelVariables.UPS;
float alpha = 0;
while (gameResources.getGlobalStates().loop) {
if (Display.timeCountRender > 1f) {
Logger.log("FPS: " + Display.fps);
Expand All @@ -178,7 +172,8 @@ public void mainLoop() {
update(interval);
accumulator -= interval;
}
render(delta);
alpha = accumulator / interval;
render(alpha);
}
dispose();
}
Expand Down Expand Up @@ -225,10 +220,6 @@ public ModInitialization getApi() {
return api;
}

public DedicatedClient getClient() {
return client;
}

public WorldsHandler getWorldsHandler() {
return worldsHandler;
}
Expand Down
Expand Up @@ -46,7 +46,7 @@ public class VoxelVariables {
public static final String apiVersion = "0.0.6";
public static final int apiVersionNum = 000006;
public static final String state = "ALPHA";
public static final int build = 145;
public static final int build = 146;
public static int FOV = 90;
public static int WIDTH = 1280;
public static int HEIGHT = 720;
Expand All @@ -59,11 +59,11 @@ public class VoxelVariables {
public static boolean autostart = false;
public static boolean christmas = false;
public static final String settings = "assets/game/settings.conf";

/**
* External Data
*/
public static final String web = "http://guerra24.net/";
public static final String web = "http://guerra24.github.io/";
/**
* Graphic Settings
*/
Expand Down
Expand Up @@ -33,7 +33,6 @@
import org.lwjgl.BufferUtils;

import net.guerra24.voxel.client.core.GlobalStates;
import net.guerra24.voxel.client.core.GlobalStates.GameState;
import net.guerra24.voxel.client.core.State;
import net.guerra24.voxel.client.core.Voxel;
import net.guerra24.voxel.client.core.VoxelVariables;
Expand All @@ -48,31 +47,26 @@
* @author danirod
* @category Kernel
*/
public class GameSPState extends State {

public GameSPState() {
super(2);
}
public class GameSPState implements State {

@Override
public void update(Voxel voxel, GlobalStates states, float delta) {
GameResources gm = voxel.getGameResources();
WorldsHandler worlds = voxel.getWorldsHandler();
Display display = voxel.getDisplay();

gm.getCamera().update(delta, gm, worlds.getActiveWorld(), voxel.getClient());
gm.getCamera().update(delta, gm, worlds.getActiveWorld());
worlds.getActiveWorld().updateChunksGeneration(gm, delta);

gm.getEngine().update(delta);
gm.getPhysicsEngine().update(delta);

gm.update(gm.getSkyboxRenderer().update(delta));
gm.getRenderer().getWaterRenderer().update(delta);
ParticleMaster.getInstance().update(delta, gm.getCamera());

//if (!display.isDisplayFocused()) {
// gm.getCamera().unlockMouse();
// states.setState(GameState.IN_PAUSE);
//}
// if (!display.isDisplayFocused()) {
// gm.getCamera().unlockMouse();
// states.setState(GameState.IN_PAUSE);
// }
}

@Override
Expand All @@ -87,7 +81,7 @@ public void render(Voxel voxel, GlobalStates states, float delta) {
gm.getMasterShadowRenderer().being();
gm.getRenderer().prepare();
worlds.getActiveWorld().updateChunksShadow(gm);
gm.getMasterShadowRenderer().renderEntity(gm.getEngine().getEntities(), gm);
gm.getMasterShadowRenderer().renderEntity(gm.getPhysicsEngine().getEntities(), gm);
gm.getMasterShadowRenderer().end();
}
gm.getFrustum().calculateFrustum(gm.getRenderer().getProjectionMatrix(), gm.getCamera());
Expand All @@ -101,7 +95,7 @@ public void render(Voxel voxel, GlobalStates states, float delta) {
FloatBuffer p = BufferUtils.createFloatBuffer(1);
glReadPixels(Display.getWidth() / 2, Display.getHeight() / 2, 1, 1, GL_DEPTH_COMPONENT, GL_FLOAT, p);
gm.getCamera().depth = p.get(0);
gm.getRenderer().renderEntity(gm.getEngine().getEntities(), gm);
gm.getRenderer().renderEntity(gm.getPhysicsEngine().getEntities(), gm);
gm.getDeferredShadingRenderer().getPost_fbo().end();

gm.getRenderer().prepare();
Expand Down
Expand Up @@ -51,11 +51,7 @@
* @author danirod
* @category Kernel
*/
public class InPauseState extends State {

public InPauseState() {
super(4);
}
public class InPauseState implements State {

@Override
public void update(Voxel voxel, GlobalStates states, float delta) {
Expand Down Expand Up @@ -88,7 +84,7 @@ public void render(Voxel voxel, GlobalStates states, float delta) {
gm.getMasterShadowRenderer().being();
gm.getRenderer().prepare();
worlds.getActiveWorld().updateChunksShadow(gm);
gm.getMasterShadowRenderer().renderEntity(gm.getEngine().getEntities(), gm);
gm.getMasterShadowRenderer().renderEntity(gm.getPhysicsEngine().getEntities(), gm);
gm.getMasterShadowRenderer().end();
}
gm.getFrustum().calculateFrustum(gm.getRenderer().getProjectionMatrix(), gm.getCamera());
Expand All @@ -102,7 +98,7 @@ public void render(Voxel voxel, GlobalStates states, float delta) {
FloatBuffer p = BufferUtils.createFloatBuffer(1);
glReadPixels(Display.getWidth() / 2, Display.getHeight() / 2, 1, 1, GL_DEPTH_COMPONENT, GL_FLOAT, p);
gm.getCamera().depth = p.get(0);
gm.getRenderer().renderEntity(gm.getEngine().getEntities(), gm);
gm.getRenderer().renderEntity(gm.getPhysicsEngine().getEntities(), gm);
gm.getDeferredShadingRenderer().getPost_fbo().end();

gm.getRenderer().prepare();
Expand Down
@@ -0,0 +1,17 @@
package net.guerra24.voxel.client.core.states;

import net.guerra24.voxel.client.core.GlobalStates;
import net.guerra24.voxel.client.core.State;
import net.guerra24.voxel.client.core.Voxel;

public class LoadingMPState implements State {

@Override
public void update(Voxel voxel, GlobalStates states, float delta) {
}

@Override
public void render(Voxel voxel, GlobalStates states, float delta) {
}

}
Expand Up @@ -39,11 +39,7 @@
* @author danirod
* @category Kernel
*/
public class LoadingState extends State {

public LoadingState() {
super(5);
}
public class LoadingSPState implements State {

@Override
public void update(Voxel voxel, GlobalStates states, float delta) {
Expand Down
Expand Up @@ -38,16 +38,11 @@
* @author danirod
* @category Kernel
*/
public class MainMenuState extends State {

public MainMenuState() {
super(1);
}
public class MainMenuState implements State {

@Override
public void render(Voxel voxel, GlobalStates states, float delta) {
GameResources gm = voxel.getGameResources();
gm.getFrustum().calculateFrustum(gm.getRenderer().getProjectionMatrix(), gm.getCamera());
gm.getRenderer().prepare();
Display.beingNVGFrame();
gm.getMenuSystem().mainMenu.render();
Expand All @@ -60,7 +55,7 @@ public void update(Voxel voxel, GlobalStates states, float delta) {
GameResources gm = voxel.getGameResources();

if (gm.getMenuSystem().mainMenu.getPlayButton().pressed()) {
states.setState(GameState.LOADING_WORLD);
states.setState(GameState.WORLD_SELECTION);
} else if (gm.getMenuSystem().mainMenu.getExitButton().pressed()) {
states.loop = false;
} else if (gm.getMenuSystem().mainMenu.getOptionsButton().pressed()) {
Expand Down

0 comments on commit 4e00e8c

Please sign in to comment.