diff options
Diffstat (limited to 'src/ru/olamedia/olacraft/game/Game.java')
-rw-r--r-- | src/ru/olamedia/olacraft/game/Game.java | 106 |
1 files changed, 106 insertions, 0 deletions
diff --git a/src/ru/olamedia/olacraft/game/Game.java b/src/ru/olamedia/olacraft/game/Game.java new file mode 100644 index 0000000..0980505 --- /dev/null +++ b/src/ru/olamedia/olacraft/game/Game.java @@ -0,0 +1,106 @@ +package ru.olamedia.olacraft.game; + +import com.jogamp.newt.opengl.GLWindow; + +import ru.olamedia.camera.MatrixCamera; +import ru.olamedia.game.GameFrame; +import ru.olamedia.olacraft.events.GameEvent; +import ru.olamedia.olacraft.network.GameClient; +import ru.olamedia.olacraft.network.GameServer; +import ru.olamedia.olacraft.scene.GameScene; +import ru.olamedia.olacraft.world.dataProvider.AbstractChunkDataProvider; +import ru.olamedia.player.Player; + +public class Game { + public static Game instance = null; + public static int port = 26002; + public static boolean isServerRunning = false; + public static GameServer server = new GameServer(); + public static GameClient client = new GameClient(); + public static Timer timer = new Timer(); + + public MatrixCamera camera; + + public static int MODE_SINGLEPLAYER = 1; + public static int MODE_MULTIPLAYER = 2; + public static int MODE_SERVER = 4; + @SuppressWarnings("unused") + private int mode = 1; + private boolean isRunning = false; + @SuppressWarnings("unused") + // player + public Player player; + + // block world + // private blockWorld; + // live entities (including player and npcs) + // private liveEntities; + public Game() { + this(MODE_SINGLEPLAYER); + } + + public Game(int mode) { + this.mode = mode; + if ((MODE_MULTIPLAYER & mode) > 0) { + if ((MODE_SERVER & mode) > 0) { + // init server + } else { + // init client + } + } + player = new Player(); + camera = new MatrixCamera(); + camera.attachTo(player); + camera.setFov(90); + camera.pack(); + // scene.registerLiveEntity(player); + } + + public void start() { + isRunning = true; + GameEvent e = new GameEvent(null); + e.setType(GameEvent.GAME_START); + e.dispatch(); + } + + // Pause game in single mode + public void pause() { + + } + + public void stop() { + + } + + public boolean isRunning() { + return isRunning; + } + + public void spawnMe(int x, int y, int z) { + player.setLocation(x, y, z); + } + + public void tick() { + timer.update(); + + } + + public static class Display { + public static int getWidth() { + return (int) GameFrame.getWidth(); + } + + public static int getHeight() { + return (int) GameFrame.getHeight(); + } + + public static float getAspect() { + return ((float) getWidth()) / ((float) getHeight()); + } + } + + public float getDelta() { + return (float) timer.getElapsedTime() / 1000; + } + +} |