diff --git a/src/main/java/com/github/halotroop/litecraft/Litecraft.java b/src/main/java/com/github/halotroop/litecraft/Litecraft.java index 8c2f2e7..88d7bca 100644 --- a/src/main/java/com/github/halotroop/litecraft/Litecraft.java +++ b/src/main/java/com/github/halotroop/litecraft/Litecraft.java @@ -32,8 +32,8 @@ public class Litecraft extends Game private LitecraftSave save; private Ginger ginger3D; private static Litecraft INSTANCE; - private Player player; - private Camera camera; + public Player player; + public Camera camera; //temp stuff to test out fbo fixes int oldWindowWidth = Window.width; int oldWindowHeight = Window.height; @@ -158,22 +158,13 @@ public class Litecraft extends Game public static Litecraft getInstance() { return INSTANCE; } - public void setGingerPlayer(Player player) - { - this.data.entities.remove(this.player); // remove the old player - this.data.player = player; // set all the player variables - this.player = player; - this.camera.player = player; - this.data.entities.add(this.player); // add the new player - } - public void onPlayButtonClick() { if (world == null) { this.save = new LitecraftSave("test", false); this.world = this.save.getWorldOrCreate(Dimensions.OVERWORLD); - this.setGingerPlayer(this.world.player); + ginger3D.setGingerPlayer(this.world.player); } } } \ No newline at end of file diff --git a/src/main/java/com/github/hydos/ginger/engine/api/Ginger.java b/src/main/java/com/github/hydos/ginger/engine/api/Ginger.java index 9e2c419..fff8b98 100644 --- a/src/main/java/com/github/hydos/ginger/engine/api/Ginger.java +++ b/src/main/java/com/github/hydos/ginger/engine/api/Ginger.java @@ -8,6 +8,7 @@ import com.github.halotroop.litecraft.logic.Timer.TickListener; import com.github.halotroop.litecraft.world.World; import com.github.hydos.ginger.engine.api.game.*; import com.github.hydos.ginger.engine.elements.buttons.TextureButton; +import com.github.hydos.ginger.engine.elements.objects.Player; import com.github.hydos.ginger.engine.font.*; import com.github.hydos.ginger.engine.io.Window; import com.github.hydos.ginger.engine.particle.ParticleMaster; @@ -48,7 +49,16 @@ public class Ginger public void openScreen(Screen screen) { gingerRegister.currentScreen = screen; } - + + public void setGingerPlayer(Player player) + { + gingerRegister.game.data.entities.remove(Litecraft.getInstance().player); // remove the old player + gingerRegister.game.data.player = player; // set all the player variables + Litecraft.getInstance().player = player; + Litecraft.getInstance().camera.player = player; + gingerRegister.game.data.entities.add(player); // add the new player + } + public void postRender() { Window.swapBuffers(); }