From 7969746bc12d6240cb9263c7e367fdaf1c2d5283 Mon Sep 17 00:00:00 2001 From: MickWerf Date: Fri, 15 May 2020 21:45:57 +0200 Subject: [PATCH] Fixed issue with build. Changed MainGame to create a thread instead of a client and used the client as input for the thread Changed client to extend Controller instead of thread --- core/src/netwerkprog/game/MainGame.java | 6 +++--- core/src/netwerkprog/game/client/Client.java | 10 ++++++---- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/core/src/netwerkprog/game/MainGame.java b/core/src/netwerkprog/game/MainGame.java index f21c24d..874d811 100644 --- a/core/src/netwerkprog/game/MainGame.java +++ b/core/src/netwerkprog/game/MainGame.java @@ -21,7 +21,7 @@ public class MainGame extends ApplicationAdapter { float screenWidth; float screenHeight; private FrameRate frameRate; - private Client client; + private Thread client; @Override public void create() { @@ -39,12 +39,12 @@ public class MainGame extends ApplicationAdapter { music.setVolume(.1f); music.play(); music.setLooping(true); - connectToServer(); } + private void connectToServer() { - client = new Client("localhost", Server.PORT); + client = new Thread(new Client("localhost", Server.PORT)); try { client.start(); } catch (Exception e) { diff --git a/core/src/netwerkprog/game/client/Client.java b/core/src/netwerkprog/game/client/Client.java index e227e8f..734b038 100644 --- a/core/src/netwerkprog/game/client/Client.java +++ b/core/src/netwerkprog/game/client/Client.java @@ -14,10 +14,7 @@ public class Client extends Controller { private String hostname; private boolean isConnected = true; - @Override - public void run() { - this.connect(); - } + public Client(String hostname, int port) { this.port = port; @@ -74,4 +71,9 @@ public class Client extends Controller { } } } + + @Override + public void run() { + this.connect(); + } }