ginger has no internal flaws what so ever
parent
02a110277e
commit
b61bce8117
|
@ -27,35 +27,7 @@ public class Litecraft extends Game{
|
|||
|
||||
private boolean isInWorld = false;
|
||||
|
||||
Timer timer;
|
||||
TickListener tickListener = new TickListener()
|
||||
{
|
||||
public void onTick(float deltaTime)
|
||||
{
|
||||
data.camera.move();
|
||||
data.player.move(null);
|
||||
|
||||
GUIText text = ginger3D.gingerRegister.texts.get(0);
|
||||
|
||||
TextureButton playButton = ginger3D.gingerRegister.guiButtons.get(0);
|
||||
|
||||
boolean isClicked = playButton.isClicked();
|
||||
|
||||
playButton.update();
|
||||
|
||||
text.setText(isClicked + "");
|
||||
|
||||
if(isClicked) {
|
||||
Window.lockMouse();
|
||||
playButton.hide(data.guis);
|
||||
isInWorld = true;
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
public Litecraft() {
|
||||
timer = new Timer(20);
|
||||
timer.addTickListener(tickListener);
|
||||
Constants.movementSpeed = 0.000005f;
|
||||
Constants.turnSpeed = 0.00002f;
|
||||
Constants.gravity = -0.000000000005f;
|
||||
|
@ -75,7 +47,7 @@ public class Litecraft extends Game{
|
|||
Camera camera = new Camera(new Vector3f(0,0.1f,0), player);
|
||||
ginger3D = new Ginger();
|
||||
|
||||
data = new GameData(player, camera);
|
||||
data = new GameData(player, camera, 20);
|
||||
data.handleGuis = false;
|
||||
ginger3D.setup(new MasterRenderer(camera), this);
|
||||
|
||||
|
@ -134,9 +106,7 @@ public class Litecraft extends Game{
|
|||
@Override
|
||||
public void render() {
|
||||
ginger3D.update(data);
|
||||
|
||||
timer.tick();
|
||||
|
||||
|
||||
if(oldWindowHeight != Window.height || oldWindowWidth != Window.width) {
|
||||
System.out.println("Windows size changed");
|
||||
ginger3D.contrastFbo.resizeFBOs();
|
||||
|
@ -162,4 +132,29 @@ public class Litecraft extends Game{
|
|||
public void exit() {
|
||||
ginger3D.cleanup();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void update()
|
||||
{
|
||||
data.camera.move();
|
||||
data.player.move(null);
|
||||
|
||||
GUIText text = ginger3D.gingerRegister.texts.get(0);
|
||||
|
||||
TextureButton playButton = ginger3D.gingerRegister.guiButtons.get(0);
|
||||
|
||||
boolean isClicked = playButton.isClicked();
|
||||
|
||||
playButton.update();
|
||||
|
||||
text.setText(isClicked + "");
|
||||
|
||||
if(isClicked) {
|
||||
Window.lockMouse();
|
||||
playButton.hide(data.guis);
|
||||
isInWorld = true;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -1,5 +1,7 @@
|
|||
package com.github.hydos.ginger.engine.api;
|
||||
|
||||
import com.github.halotroop.litecraft.logic.Timer;
|
||||
import com.github.halotroop.litecraft.logic.Timer.TickListener;
|
||||
import com.github.hydos.ginger.engine.api.game.*;
|
||||
import com.github.hydos.ginger.engine.elements.buttons.TextureButton;
|
||||
import com.github.hydos.ginger.engine.font.*;
|
||||
|
@ -23,11 +25,26 @@ public class Ginger {
|
|||
|
||||
public Fbo contrastFbo;
|
||||
|
||||
Timer timer;
|
||||
|
||||
TickListener gameTickListener = new TickListener()
|
||||
{
|
||||
public void onTick(float deltaTime)
|
||||
{
|
||||
gingerRegister.game.update();
|
||||
};
|
||||
};
|
||||
|
||||
public void setup(MasterRenderer masterRenderer, Game game) {
|
||||
gingerRegister = new GingerRegister();
|
||||
gingerRegister.registerGame(game);
|
||||
|
||||
timer = new Timer(game.data.tickSpeed);
|
||||
timer.addTickListener(gameTickListener);
|
||||
|
||||
contrastFbo = new Fbo(new ContrastChanger());
|
||||
this.masterRenderer = masterRenderer;
|
||||
|
||||
picker = new MousePicker(game.data.camera, masterRenderer.getProjectionMatrix(), null);
|
||||
PostProcessing.init();
|
||||
ParticleMaster.init(masterRenderer.getProjectionMatrix());
|
||||
|
@ -38,6 +55,7 @@ public class Ginger {
|
|||
while(!Window.closed()) {
|
||||
|
||||
if(Window.isUpdating()) {
|
||||
timer.tick();
|
||||
gingerRegister.game.render();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,4 +10,6 @@ public abstract class Game {
|
|||
|
||||
public abstract void exit();
|
||||
|
||||
public abstract void update();
|
||||
|
||||
}
|
|
@ -24,8 +24,9 @@ public class GameData {
|
|||
public Camera camera;
|
||||
public Vector4f clippingPlane;
|
||||
public boolean handleGuis = true;
|
||||
public int tickSpeed = 0;
|
||||
|
||||
public GameData(Player player, Camera camera) {
|
||||
public GameData(Player player, Camera camera, int tickSpeed) {
|
||||
clippingPlane = new Vector4f(0, -1, 0, 100000);
|
||||
guis = new ArrayList<GuiTexture>();
|
||||
entities = new ArrayList<RenderObject>();
|
||||
|
@ -34,6 +35,7 @@ public class GameData {
|
|||
flatTerrains = new ArrayList<Terrain>();
|
||||
this.player = player;
|
||||
this.camera = camera;
|
||||
this.tickSpeed = tickSpeed;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue