Restructured Util for better usability
Moved MainGame from util to client. Moved server port static from serverData to Data
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
package netwerkprog.game.client;
|
||||
|
||||
import netwerkprog.game.util.Controller;
|
||||
import netwerkprog.game.util.ServerData;
|
||||
import netwerkprog.game.util.application.Controller;
|
||||
import netwerkprog.game.util.data.Data;
|
||||
import netwerkprog.game.util.data.DataParser;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
@@ -13,13 +14,20 @@ import java.util.Scanner;
|
||||
public class Client extends Controller {
|
||||
private int port;
|
||||
private String hostname;
|
||||
private DataParser parser;
|
||||
private boolean isConnected = true;
|
||||
|
||||
|
||||
|
||||
public Client(String hostname) {
|
||||
this.port = ServerData.port();
|
||||
this.port = Data.port();
|
||||
this.hostname = hostname;
|
||||
this.parser = new DataParser();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
this.connect();
|
||||
}
|
||||
|
||||
public void connect() {
|
||||
@@ -66,15 +74,12 @@ public class Client extends Controller {
|
||||
while (isConnected) {
|
||||
try {
|
||||
received = in.readUTF();
|
||||
System.out.println(received);
|
||||
|
||||
} catch (IOException e) {
|
||||
System.out.println("exception caught - " + e.getMessage());;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
this.connect();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package netwerkprog.game;
|
||||
package netwerkprog.game.client;
|
||||
|
||||
import com.badlogic.gdx.ApplicationAdapter;
|
||||
import com.badlogic.gdx.Files;
|
||||
@@ -7,8 +7,7 @@ import com.badlogic.gdx.audio.Music;
|
||||
import com.badlogic.gdx.graphics.GL20;
|
||||
import com.badlogic.gdx.graphics.Texture;
|
||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
|
||||
import netwerkprog.game.client.Client;
|
||||
import netwerkprog.game.util.FrameRate;
|
||||
import netwerkprog.game.util.graphics.FrameRate;
|
||||
|
||||
public class MainGame extends ApplicationAdapter {
|
||||
SpriteBatch batch;
|
||||
@@ -1,6 +1,6 @@
|
||||
package netwerkprog.game.client.game;
|
||||
|
||||
import netwerkprog.game.util.Controller;
|
||||
import netwerkprog.game.util.application.Controller;
|
||||
|
||||
public class Game extends Controller {
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package netwerkprog.game.client.game;
|
||||
|
||||
import netwerkprog.game.util.Controller;
|
||||
import netwerkprog.game.util.application.Controller;
|
||||
|
||||
public class Graphics extends Controller {
|
||||
public Graphics() {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package netwerkprog.game.client.game.logic;
|
||||
|
||||
import netwerkprog.game.util.Controller;
|
||||
import netwerkprog.game.util.application.Controller;
|
||||
|
||||
public class Logic extends Controller {
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ package netwerkprog.game.client.game.map;
|
||||
|
||||
import com.badlogic.gdx.graphics.g2d.Batch;
|
||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
|
||||
import netwerkprog.game.util.Renderable;
|
||||
import netwerkprog.game.util.graphics.Renderable;
|
||||
|
||||
public class MapRenderer implements Renderable {
|
||||
private int tileWidth;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package netwerkprog.game.server;
|
||||
|
||||
import netwerkprog.game.server.controllers.SessionController;
|
||||
import netwerkprog.game.server.data.Data;
|
||||
import netwerkprog.game.util.data.Data;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
package netwerkprog.game.server.controllers;
|
||||
|
||||
import netwerkprog.game.server.ServerClient;
|
||||
import netwerkprog.game.server.data.Data;
|
||||
import netwerkprog.game.server.data.DataParser;
|
||||
import netwerkprog.game.util.Controller;
|
||||
import netwerkprog.game.util.ServerData;
|
||||
import netwerkprog.game.util.data.Data;
|
||||
import netwerkprog.game.util.data.DataParser;
|
||||
import netwerkprog.game.util.application.Controller;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
@@ -46,8 +45,8 @@ public class SessionController extends Controller {
|
||||
*/
|
||||
public void listen() {
|
||||
try {
|
||||
this.serverSocket = new ServerSocket(ServerData.port());
|
||||
System.out.println("[SERVER] listening on port " + ServerData.port());
|
||||
this.serverSocket = new ServerSocket(Data.port());
|
||||
System.out.println("[SERVER] listening on port " + Data.port());
|
||||
registerClient(serverSocket.accept());
|
||||
this.serverSocket.close();
|
||||
} catch (IOException ex) {
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
package netwerkprog.game.server.data;
|
||||
|
||||
public class Data {
|
||||
}
|
||||
@@ -1,4 +0,0 @@
|
||||
package netwerkprog.game.server.data;
|
||||
|
||||
public class Event {
|
||||
}
|
||||
@@ -1,4 +0,0 @@
|
||||
package netwerkprog.game.util;
|
||||
|
||||
public enum Faction {
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
package netwerkprog.game.util;
|
||||
|
||||
public interface Renderable extends Updatable {
|
||||
void render();
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package netwerkprog.game.util;
|
||||
package netwerkprog.game.util.application;
|
||||
|
||||
public abstract class Controller implements Runnable {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package netwerkprog.game.util;
|
||||
package netwerkprog.game.util.application;
|
||||
|
||||
import com.badlogic.gdx.backends.lwjgl.LwjglApplicationConfiguration;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package netwerkprog.game.util;
|
||||
package netwerkprog.game.util.application;
|
||||
|
||||
public class Timer implements Updatable {
|
||||
private double wait;
|
||||
@@ -1,4 +1,4 @@
|
||||
package netwerkprog.game.util;
|
||||
package netwerkprog.game.util.application;
|
||||
|
||||
public interface Updatable {
|
||||
void update(double deltaTime);
|
||||
@@ -1,4 +1,4 @@
|
||||
package netwerkprog.game.util;
|
||||
package netwerkprog.game.util.data;
|
||||
|
||||
public interface Callback {
|
||||
void onDataReceived();
|
||||
@@ -1,7 +1,6 @@
|
||||
package netwerkprog.game.util;
|
||||
|
||||
public class ServerData {
|
||||
package netwerkprog.game.util.data;
|
||||
|
||||
public class Data {
|
||||
public static int port() {
|
||||
return 8000;
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package netwerkprog.game.server.data;
|
||||
package netwerkprog.game.util.data;
|
||||
|
||||
public class DataParser {
|
||||
public DataParser() {
|
||||
4
core/src/netwerkprog/game/util/data/Event.java
Normal file
4
core/src/netwerkprog/game/util/data/Event.java
Normal file
@@ -0,0 +1,4 @@
|
||||
package netwerkprog.game.util.data;
|
||||
|
||||
public class Event {
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package netwerkprog.game.util;
|
||||
package netwerkprog.game.util.game;
|
||||
|
||||
public abstract class Ability {
|
||||
protected String name;
|
||||
@@ -1,4 +1,4 @@
|
||||
package netwerkprog.game.util;
|
||||
package netwerkprog.game.util.game;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
4
core/src/netwerkprog/game/util/game/Faction.java
Normal file
4
core/src/netwerkprog/game/util/game/Faction.java
Normal file
@@ -0,0 +1,4 @@
|
||||
package netwerkprog.game.util.game;
|
||||
|
||||
public enum Faction {
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package netwerkprog.game.util;
|
||||
package netwerkprog.game.util.graphics;
|
||||
|
||||
import com.badlogic.gdx.Gdx;
|
||||
import com.badlogic.gdx.graphics.OrthographicCamera;
|
||||
7
core/src/netwerkprog/game/util/graphics/Renderable.java
Normal file
7
core/src/netwerkprog/game/util/graphics/Renderable.java
Normal file
@@ -0,0 +1,7 @@
|
||||
package netwerkprog.game.util.graphics;
|
||||
|
||||
import netwerkprog.game.util.application.Updatable;
|
||||
|
||||
public interface Renderable extends Updatable {
|
||||
void render();
|
||||
}
|
||||
@@ -1,8 +1,8 @@
|
||||
package netwerkprog.game.desktop;
|
||||
|
||||
import com.badlogic.gdx.backends.lwjgl.LwjglApplication;
|
||||
import netwerkprog.game.MainGame;
|
||||
import netwerkprog.game.util.GameApplicationConfiguration;
|
||||
import netwerkprog.game.client.MainGame;
|
||||
import netwerkprog.game.util.application.GameApplicationConfiguration;
|
||||
|
||||
public class DesktopLauncher {
|
||||
public static void main (String[] arg) {
|
||||
|
||||
Reference in New Issue
Block a user