diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..d472d6f6 --- /dev/null +++ b/.gitignore @@ -0,0 +1,8 @@ +*.lib.xml +Tank game - Client\.idea\libraries\lib.xml +Tank game - Client\.idea\libraries +Tank game - Client\.idea +Tank game - Client\out +Tank game - Client/.idea/libraries/lib.xml +*.xml +*.xml diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 00000000..5773d1b1 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,11 @@ +# Default ignored files +.Gruppe-306-PCSS-.iml +.misc.xml +.modules.xml +.uiDesigner.xml +.vcs.xml +.workspace.xml +*.log +*.xml +*.json + diff --git a/.idea/Gruppe-306-PCSS.iml b/.idea/Gruppe-306-PCSS.iml new file mode 100644 index 00000000..caa038c6 --- /dev/null +++ b/.idea/Gruppe-306-PCSS.iml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/lib.xml b/.idea/libraries/lib.xml new file mode 100644 index 00000000..59fbaf73 --- /dev/null +++ b/.idea/libraries/lib.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 00000000..51a084d8 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,9 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 00000000..eae67bba --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/shelf/Uncommitted_changes_before_Checkout_at_27_10_2020_13_00_[Default_Changelist]/Lobby.class b/.idea/shelf/Uncommitted_changes_before_Checkout_at_27_10_2020_13_00_[Default_Changelist]/Lobby.class new file mode 100644 index 00000000..aedb7b04 Binary files /dev/null and b/.idea/shelf/Uncommitted_changes_before_Checkout_at_27_10_2020_13_00_[Default_Changelist]/Lobby.class differ diff --git a/.idea/shelf/Uncommitted_changes_before_Checkout_at_27_10_2020_13_00_[Default_Changelist]/LobbySender.class b/.idea/shelf/Uncommitted_changes_before_Checkout_at_27_10_2020_13_00_[Default_Changelist]/LobbySender.class new file mode 100644 index 00000000..647fd7c0 Binary files /dev/null and b/.idea/shelf/Uncommitted_changes_before_Checkout_at_27_10_2020_13_00_[Default_Changelist]/LobbySender.class differ diff --git a/.idea/shelf/Uncommitted_changes_before_Checkout_at_27_10_2020_13_00_[Default_Changelist]/LobbySender1.class b/.idea/shelf/Uncommitted_changes_before_Checkout_at_27_10_2020_13_00_[Default_Changelist]/LobbySender1.class new file mode 100644 index 00000000..647fd7c0 Binary files /dev/null and b/.idea/shelf/Uncommitted_changes_before_Checkout_at_27_10_2020_13_00_[Default_Changelist]/LobbySender1.class differ diff --git a/.idea/shelf/Uncommitted_changes_before_Checkout_at_27_10_2020_13_00_[Default_Changelist]/shelved.patch b/.idea/shelf/Uncommitted_changes_before_Checkout_at_27_10_2020_13_00_[Default_Changelist]/shelved.patch new file mode 100644 index 00000000..45eac53a --- /dev/null +++ b/.idea/shelf/Uncommitted_changes_before_Checkout_at_27_10_2020_13_00_[Default_Changelist]/shelved.patch @@ -0,0 +1,287 @@ +Index: Tank game - Client/src/Lobby.java +IDEA additional info: +Subsystem: com.intellij.openapi.diff.impl.patch.BaseRevisionTextPatchEP +<+>import java.io.IOException;\r\nimport java.util.ArrayList;\r\nimport java.util.List;\r\nimport java.util.Scanner;\r\nimport java.util.concurrent.atomic.AtomicReference;\r\n\r\npublic class Lobby{\r\n\r\n // private ListactiveGameName = new ArrayList();\r\n private List subLobbies = new ArrayList();\r\n public static List players = new ArrayList<>();\r\n \r\n private String playerID;\r\n private boolean isHost;\r\n private String currentLobby;\r\n private LobbySender sender;\r\n\r\n Scanner scanner = new Scanner(System.in);\r\n\r\n\r\n Lobby() throws IOException {\r\n\r\n\r\n System.out.println(\"Welcome to TANK the game!\");\r\n\r\n\r\n\r\n System.out.println(\"What is your name?\");\r\n String id = scanner.nextLine();\r\n this.playerID = id;\r\n sender = new LobbySender(id);\r\n sender.setPlayerID(id);\r\n sender.sendPlayerID();\r\n options();\r\n }\r\n\r\n public String PlayerID(){\r\n return playerID;\r\n }\r\n\r\n\r\n\r\n void createLobby(String code) throws IOException {\r\n SubLobby subLobby = new SubLobby(code, this.playerID);\r\n this.subLobbies.add(subLobby);\r\n sender.sendSubLobby(subLobby);\r\n }\r\n\r\n\r\n void updateLobbies(List s) throws IOException{\r\n for(int i = 0; i < s.size(); i++) {\r\n if(subLobbies.size() == 0){\r\n subLobbies.add(s.get(i));\r\n System.out.println(\"New lobby found!: \"+s.get(i).getLobbyName());\r\n break;\r\n }\r\n for (int j = 0; j newPlayers = sender.updatePlayers(this.currentLobby);\r\n\r\n for(int i = 0; i < subLobbies.size(); i++) {\r\n if(subLobbies.get(i).getLobbyName().equals(this.currentLobby)){\r\n subLobbies.get(i).setPlayers(newPlayers);\r\n\r\n }\r\n }\r\n }\r\n\r\n void hostOptions(String lobbyName) {\r\n System.out.println(\"Write \\\"ready\\\" if you are ready to start the game, or write \\\"list\\\" to see player list.\");\r\n System.out.println(\"Write \\\"exit\\\" to leave lobby\");\r\n\r\n try {\r\n String input = scanner.nextLine();\r\n if (input.equals(\"ready\")) {\r\n readyCheck();\r\n //startGame(lobbyName); //Start ny instance af et game!\r\n } else if (input.equals(\"list\")) {\r\n updatePlayers();\r\n for (int i = 0; i < subLobbies.size(); i++) {\r\n if (subLobbies.get(i).getLobbyName().equals(lobbyName)) {\r\n subLobbies.get(i).printPlayers();\r\n }\r\n }\r\n\r\n\r\n hostOptions(lobbyName);\r\n } else if (input.equals(\"exit\")) {\r\n removeFromLobby(lobbyName);\r\n } else {\r\n System.out.println(\"Unknown input, try again\");\r\n hostOptions(lobbyName);\r\n }\r\n } catch (Exception e) {\r\n System.out.println(e);\r\n System.out.println(\"Unknown input, try again\");\r\n hostOptions(lobbyName);\r\n }\r\n\r\n }\r\n\r\n void options() {\r\n System.out.println(\"Write \\\"create\\\" if you want to create a new game, or write \\\"join\\\" to see a list of available games\");\r\n String option = scanner.nextLine();\r\n try {\r\n if (option.equals(\"create\")) {\r\n System.out.println(\"Creating Lobby. What should the lobby be named?\");\r\n String lobbyName = scanner.nextLine();\r\n createLobby(lobbyName);\r\n this.currentLobby = lobbyName;\r\n isHost = true;\r\n } else if (option.equals(\"join\")) {\r\n updateLobbies(sender.requestLobbyList());\r\n\r\n if (subLobbies.size() == 0) {\r\n System.out.println(\"No available games at the moment :(\");\r\n options();\r\n }\r\n\r\n System.out.println(\"Which lobby would you like to join? Here is a list of active games\");\r\n for (int i = 0; i < subLobbies.size(); i++) {\r\n System.out.println(subLobbies.get(i).getLobbyName() + \" (\" + subLobbies.get(i).getPlayers().size() + \"/4)\");\r\n }\r\n String lobbyName = scanner.nextLine();\r\n this.currentLobby = lobbyName;\r\n isHost = false;\r\n\r\n joinLobby(lobbyName); //Try Catch her måske, kommer and på hvad funktionen skal\r\n } else {\r\n System.out.println(\"please enter a valid option\");\r\n options();\r\n }\r\n } catch (Exception e) {\r\n System.out.println(e);\r\n System.out.println(\"please enter a valid option\");\r\n options();\r\n }\r\n\r\n if (this.isHost) {\r\n hostOptions(this.currentLobby);\r\n } else {\r\n playerOptions(this.currentLobby);\r\n }\r\n }\r\n\r\n\r\n\r\n public static void main(String[] args) throws IOException {\r\n\r\n Lobby l = new Lobby();\r\n\r\n\r\n\r\n }\r\n}\r\n +Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP +<+>UTF-8 +=================================================================== +--- Tank game - Client/src/Lobby.java (revision 2e862df7fcdef049ad2d380d7e5ca16722c1ac85) ++++ Tank game - Client/src/Lobby.java (date 1603717520519) +@@ -9,7 +9,7 @@ + // private ListactiveGameName = new ArrayList(); + private List subLobbies = new ArrayList(); + public static List players = new ArrayList<>(); +- ++ + private String playerID; + private boolean isHost; + private String currentLobby; +@@ -113,7 +113,6 @@ + } + } + } +- + options(); + } + +@@ -129,8 +128,6 @@ + if(input.equals("ready")){ + readyCheck(); + } +- +- + if (input.equals("exit")) { + removeFromLobby(lobbyName); + } else if (input.equals("list")) { +Index: Tank game - Client/src/Game.java +IDEA additional info: +Subsystem: com.intellij.openapi.diff.impl.patch.BaseRevisionTextPatchEP +<+>import javafx.animation.AnimationTimer;\r\nimport javafx.application.Application;\r\nimport javafx.scene.Parent;\r\nimport javafx.scene.Scene;\r\nimport javafx.scene.layout.Pane;\r\nimport javafx.scene.paint.Color;\r\nimport javafx.stage.Stage;\r\n\r\nimport java.io.InputStream;\r\nimport java.util.ArrayList;\r\nimport java.util.List;\r\n\r\n\r\npublic class Game extends Application {\r\n\r\n Projectile[] projectiles;\r\n\r\n InputStream in = LobbySender.getFromServer();\r\n\r\n //movement booleans\r\n boolean left = false;\r\n boolean right = false;\r\n boolean forward = false;\r\n boolean backward = false;\r\n\r\n\r\n private Pane root = new Pane(); //initializes a Pane called root\r\n\r\n //size of the window\r\n int width = 1200;\r\n int height = 700;\r\n\r\n int wallWidth = 10;\r\n\r\n String playerID;\r\n\r\n private Tank player = new Tank(300, 300, 70, 40, playerID, Color.BLUE);\r\n private Tank player2 = new Tank(100, 100, 70, 40, \"2\", Color.BISQUE);\r\n Tank[] tanks = {player, player2};//puts the tanks into an array\r\n //private List tank = new ArrayList();\r\n\r\n\r\n //map\r\n private Map top = new Map(0, 0, 1200, wallWidth);\r\n private Map bund = new Map(0, height - wallWidth, 1200, wallWidth);\r\n private Map hoejre = new Map(width - wallWidth, 0, wallWidth, height);\r\n private Map venstre = new Map(0, 0, wallWidth, height);\r\n private Map map1 = new Map(200, 100, width / 2, wallWidth);\r\n Map[] maps = {top, bund, venstre, hoejre, map1};\r\n\r\n\r\n\r\n\r\n private Parent createContent() { //creates the \"draw\" function - creates a Parent and returns it\r\n root.setPrefSize(width, height); //sets width and height of window\r\n\r\n for(int i = 0; i< tanks.length; i++){ //makes the tanks\r\n if(tanks[i] != null) {\r\n root.getChildren().add(tanks[i]);\r\n }\r\n }\r\n\r\n for (int i = 0; i < maps.length; i++) {\r\n root.getChildren().add(maps[i]);\r\n }\r\n\r\n AnimationTimer timer = new AnimationTimer() { //everything in this is called each frame\r\n @Override\r\n public void handle(long now) {\r\n update();\r\n }\r\n };\r\n timer.start(); //starts the animationtimer\r\n return root; //returns the root\r\n }\r\n\r\n public void update() {//function where everything that happens every frame is called\r\n //moves ALL bullets on the map\r\n for (int i = 0; i < projectiles.length; i++) {\r\n if (projectiles[i] != null) { //only does this function if there are bullets in the array\r\n for (int j = 0; j < maps.length; j++) {\r\n projectiles[i].moveBullet(maps[j]);//moves bullets\r\n }\r\n\r\n //removes a tank if hit\r\n if (projectiles[i].collision(tanks) != null) {//only does this if there is a hit tank\r\n\r\n Tank tank = projectiles[i].collision(tanks);\r\n if (tank.getDead() == false) {\r\n root.getChildren().remove(tank);\r\n root.getChildren().remove(projectiles[i]);//removes the bullet visually\r\n projectiles[i] = null;//removes the bullets from the array\r\n }\r\n tank.setDead();\r\n //root.getChildren().remove(projectiles[i].collision(tanks));//removes the tank visually\r\n\r\n\r\n }\r\n }\r\n }\r\n\r\n //checks the lifespan and removes bullet if it is over a threshold\r\n int threshold = 3000; //threshold - the bullets are removed after 300 frames\r\n for (int i = 0; i < projectiles.length; i++) {\r\n if (projectiles[i] != null && projectiles[i].getLifespan() >= threshold) { //only does this if there are bullets on the map and if one have been alive for 300 frames\r\n root.getChildren().remove(projectiles[i]); //removes the projectile child\r\n projectiles[i] = null; //removes projectile from array.\r\n }\r\n }\r\n/*\r\n if (left) { //moves if the boolean is true, this is smoother than having the move in the start function\r\n player.rotateLeft();\r\n if (player.isColliding(maps)){\r\n player.rotateRight();\r\n\r\n }\r\n }\r\n if (right) {\r\n player.rotateRight();\r\n if (player.isColliding(maps)){\r\n player.rotateLeft();\r\n }\r\n }\r\n if (forward) {\r\n player.moveForward();\r\n if (player.isColliding(maps)){\r\n player.moveBackward();\r\n\r\n }\r\n }\r\n if (backward) {\r\n player.moveBackward();\r\n if (player.isColliding(maps)){\r\n player.moveForward();\r\n\r\n }\r\n }\r\n */\r\n\r\n }\r\n\r\n\r\n public void start(Stage stage) throws Exception {\r\n Scene scene = new Scene(createContent()); //creates a scene with the root createContent as input\r\n projectiles = player.getProjectiles(); //initializes the projectile array\r\n Parameters para = getParameters();\r\n List list = para.getRaw();\r\n playerID = list.get(0);\r\n System.out.println(list.get(0));\r\n\r\n\r\n //sets booleans to false if key is released\r\n scene.setOnKeyReleased(e -> {\r\n switch (e.getCode()) {\r\n case LEFT:\r\n left = false;\r\n break;\r\n case RIGHT:\r\n right = false;\r\n break;\r\n case UP:\r\n forward = false;\r\n break;\r\n case DOWN:\r\n backward = false;\r\n break;\r\n }\r\n });\r\n\r\n //sets booleans to true if key is pressed\r\n scene.setOnKeyPressed(e -> {\r\n switch (e.getCode()) {\r\n case LEFT:\r\n left = true;\r\n break;\r\n case RIGHT:\r\n right = true;\r\n break;\r\n case UP:\r\n forward = true;\r\n break;\r\n case DOWN:\r\n backward = true;\r\n break;\r\n case SPACE:\r\n Projectile p = player.shoot();\r\n projectiles = player.getProjectiles();\r\n if (p != null) {\r\n root.getChildren().add(p);\r\n }\r\n break;\r\n }\r\n });\r\n stage.setScene(scene);//creates a stage using the scene that uses the root\r\n stage.show();\r\n }\r\n\r\n\r\n\r\n public static void main(String[] args) {\r\n launch(args);\r\n }\r\n}\r\n +Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP +<+>UTF-8 +=================================================================== +--- Tank game - Client/src/Game.java (revision 2e862df7fcdef049ad2d380d7e5ca16722c1ac85) ++++ Tank game - Client/src/Game.java (date 1603720306754) +@@ -49,13 +49,11 @@ + Map[] maps = {top, bund, venstre, hoejre, map1}; + + +- +- + private Parent createContent() { //creates the "draw" function - creates a Parent and returns it + root.setPrefSize(width, height); //sets width and height of window + +- for(int i = 0; i< tanks.length; i++){ //makes the tanks +- if(tanks[i] != null) { ++ for (int i = 0; i < tanks.length; i++) { //makes the tanks ++ if (tanks[i] != null) { + root.getChildren().add(tanks[i]); + } + } +@@ -107,35 +105,34 @@ + projectiles[i] = null; //removes projectile from array. + } + } +-/* ++ + if (left) { //moves if the boolean is true, this is smoother than having the move in the start function + player.rotateLeft(); +- if (player.isColliding(maps)){ ++ if (player.isColliding(maps)) { + player.rotateRight(); + + } + } + if (right) { + player.rotateRight(); +- if (player.isColliding(maps)){ ++ if (player.isColliding(maps)) { + player.rotateLeft(); + } + } + if (forward) { + player.moveForward(); +- if (player.isColliding(maps)){ ++ if (player.isColliding(maps)) { + player.moveBackward(); + + } + } + if (backward) { + player.moveBackward(); +- if (player.isColliding(maps)){ ++ if (player.isColliding(maps)) { + player.moveForward(); + + } + } +- */ + + } + +@@ -196,7 +193,6 @@ + } + + +- + public static void main(String[] args) { + launch(args); + } +Index: .idea/workspace.xml +IDEA additional info: +Subsystem: com.intellij.openapi.diff.impl.patch.BaseRevisionTextPatchEP +<+>\r\n\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n 1602501096197\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n +Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP +<+>UTF-8 +=================================================================== +--- .idea/workspace.xml (revision 2e862df7fcdef049ad2d380d7e5ca16722c1ac85) ++++ .idea/workspace.xml (date 1603785626481) +@@ -2,29 +2,17 @@ + + + +- +- +- +- +- +- + + +- +- +- + + +- +- +- +- +- +- ++ ++ ++ ++ + + + +- + + +@@ -145,22 +133,22 @@ + + + +- ++ + + +- +- ++ ++ + + +- +- ++ ++ + + +- +- ++ ++ + + +- ++ + + + +Index: Tank game - Client/.idea/workspace.xml +IDEA additional info: +Subsystem: com.intellij.openapi.diff.impl.patch.BaseRevisionTextPatchEP +<+>\r\n\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n 1601469582604\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n +Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP +<+>UTF-8 +=================================================================== +--- Tank game - Client/.idea/workspace.xml (revision 2e862df7fcdef049ad2d380d7e5ca16722c1ac85) ++++ Tank game - Client/.idea/workspace.xml (date 1603785616180) +@@ -2,29 +2,17 @@ + + + +- +- +- +- +- +- + + +- +- +- + + +- +- +- +- +- +- ++ ++ ++ ++ + + + +- + + + +- ++ + + +- ++ + + + +@@ -195,22 +184,22 @@ + + + +- ++ + + +- +- ++ ++ + + +- +- ++ ++ + + +- +- ++ ++ + + +- ++ + + + diff --git a/.idea/shelf/Uncommitted_changes_before_Checkout_at_27_10_2020_13_00_[Default_Changelist]1/Lobby.class b/.idea/shelf/Uncommitted_changes_before_Checkout_at_27_10_2020_13_00_[Default_Changelist]1/Lobby.class new file mode 100644 index 00000000..aedb7b04 Binary files /dev/null and b/.idea/shelf/Uncommitted_changes_before_Checkout_at_27_10_2020_13_00_[Default_Changelist]1/Lobby.class differ diff --git a/.idea/shelf/Uncommitted_changes_before_Checkout_at_27_10_2020_13_00_[Default_Changelist]1/LobbySender.class b/.idea/shelf/Uncommitted_changes_before_Checkout_at_27_10_2020_13_00_[Default_Changelist]1/LobbySender.class new file mode 100644 index 00000000..647fd7c0 Binary files /dev/null and b/.idea/shelf/Uncommitted_changes_before_Checkout_at_27_10_2020_13_00_[Default_Changelist]1/LobbySender.class differ diff --git a/.idea/shelf/Uncommitted_changes_before_Checkout_at_27_10_2020_13_00_[Default_Changelist]1/shelved.patch b/.idea/shelf/Uncommitted_changes_before_Checkout_at_27_10_2020_13_00_[Default_Changelist]1/shelved.patch new file mode 100644 index 00000000..e69de29b diff --git a/.idea/shelf/Uncommitted_changes_before_Checkout_at_27_10_2020_13_01_[Default_Changelist]/shelved.patch b/.idea/shelf/Uncommitted_changes_before_Checkout_at_27_10_2020_13_01_[Default_Changelist]/shelved.patch new file mode 100644 index 00000000..e69de29b diff --git a/.idea/shelf/Uncommitted_changes_before_Checkout_at_27_10_2020_13_03_[Default_Changelist]/shelved.patch b/.idea/shelf/Uncommitted_changes_before_Checkout_at_27_10_2020_13_03_[Default_Changelist]/shelved.patch new file mode 100644 index 00000000..fa317a6e --- /dev/null +++ b/.idea/shelf/Uncommitted_changes_before_Checkout_at_27_10_2020_13_03_[Default_Changelist]/shelved.patch @@ -0,0 +1,55 @@ +Index: .idea/workspace.xml +IDEA additional info: +Subsystem: com.intellij.openapi.diff.impl.patch.BaseRevisionTextPatchEP +<+>\r\n\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n 1602501096197\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n +Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP +<+>UTF-8 +=================================================================== +--- .idea/workspace.xml (revision 4698d869c9cd6993acc1535ccf5fa0742580797d) ++++ .idea/workspace.xml (date 1603800154859) +@@ -2,29 +2,10 @@ + + + +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- ++ ++ ++ ++ + + + + ++ + + diff --git a/.idea/shelf/Uncommitted_changes_before_Checkout_at_27_10_2020_14_29_[Default_Changelist]/Game$2.class b/.idea/shelf/Uncommitted_changes_before_Checkout_at_27_10_2020_14_29_[Default_Changelist]/Game$2.class new file mode 100644 index 00000000..47f805e2 Binary files /dev/null and b/.idea/shelf/Uncommitted_changes_before_Checkout_at_27_10_2020_14_29_[Default_Changelist]/Game$2.class differ diff --git a/.idea/shelf/Uncommitted_changes_before_Checkout_at_27_10_2020_14_29_[Default_Changelist]/Game.class b/.idea/shelf/Uncommitted_changes_before_Checkout_at_27_10_2020_14_29_[Default_Changelist]/Game.class new file mode 100644 index 00000000..1f33ce9b Binary files /dev/null and b/.idea/shelf/Uncommitted_changes_before_Checkout_at_27_10_2020_14_29_[Default_Changelist]/Game.class differ diff --git a/.idea/shelf/Uncommitted_changes_before_Checkout_at_27_10_2020_14_29_[Default_Changelist]/Tank.class b/.idea/shelf/Uncommitted_changes_before_Checkout_at_27_10_2020_14_29_[Default_Changelist]/Tank.class new file mode 100644 index 00000000..9c68233e Binary files /dev/null and b/.idea/shelf/Uncommitted_changes_before_Checkout_at_27_10_2020_14_29_[Default_Changelist]/Tank.class differ diff --git a/.idea/shelf/Uncommitted_changes_before_Checkout_at_27_10_2020_14_29_[Default_Changelist]/shelved.patch b/.idea/shelf/Uncommitted_changes_before_Checkout_at_27_10_2020_14_29_[Default_Changelist]/shelved.patch new file mode 100644 index 00000000..f05aaffe --- /dev/null +++ b/.idea/shelf/Uncommitted_changes_before_Checkout_at_27_10_2020_14_29_[Default_Changelist]/shelved.patch @@ -0,0 +1,205 @@ +Index: .idea/workspace.xml +IDEA additional info: +Subsystem: com.intellij.openapi.diff.impl.patch.BaseRevisionTextPatchEP +<+>\r\n\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n 1602501096197\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n +Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP +<+>UTF-8 +=================================================================== +--- .idea/workspace.xml (revision 54507ef68ccb0d9908ed2cf5560d73924a5ab393) ++++ .idea/workspace.xml (date 1603803752855) +@@ -2,20 +2,17 @@ + + + +- + +- + + + +- ++ + +- +- +- +- +- ++ ++ ++ + ++ + + + + ++ + + ++ ++ ++ + + +- ++ + + + +@@ -111,58 +128,91 @@ + + + +- ++ ++ + ++ ++ 1603800135439 ++ ++ + +- ++ ++ ++ + +- ++ + + +- +- ++ ++ + + +- ++ + + + + +- ++ ++ ++ ++ ++ + + +- +- ++ ++ + + +- ++ + + + + +- ++ ++ ++ ++ ++ ++ ++ ++ ++ + + +- +- ++ ++ + + +- +- ++ ++ + + +- +- ++ ++ + + +- +- ++ ++ + + +- ++ ++ ++ ++ ++ ++ ++ ++ ++ + + + diff --git a/.idea/shelf/Uncommitted_changes_before_Update_at_27_10_2020_13_02_[Default_Changelist]/shelved.patch b/.idea/shelf/Uncommitted_changes_before_Update_at_27_10_2020_13_02_[Default_Changelist]/shelved.patch new file mode 100644 index 00000000..e52581b9 --- /dev/null +++ b/.idea/shelf/Uncommitted_changes_before_Update_at_27_10_2020_13_02_[Default_Changelist]/shelved.patch @@ -0,0 +1,55 @@ +Index: .idea/workspace.xml +IDEA additional info: +Subsystem: com.intellij.openapi.diff.impl.patch.BaseRevisionTextPatchEP +<+>\r\n\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n 1602501096197\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n +Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP +<+>UTF-8 +=================================================================== +--- .idea/workspace.xml (revision 2e862df7fcdef049ad2d380d7e5ca16722c1ac85) ++++ .idea/workspace.xml (date 1603800097450) +@@ -2,29 +2,10 @@ + + + +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- ++ ++ ++ ++ + + + + ++ + + diff --git a/.idea/shelf/Uncommitted_changes_before_Update_at_27_10_2020_13_16_[Default_Changelist]/Game$1.class b/.idea/shelf/Uncommitted_changes_before_Update_at_27_10_2020_13_16_[Default_Changelist]/Game$1.class new file mode 100644 index 00000000..3c9caa4a Binary files /dev/null and b/.idea/shelf/Uncommitted_changes_before_Update_at_27_10_2020_13_16_[Default_Changelist]/Game$1.class differ diff --git a/.idea/shelf/Uncommitted_changes_before_Update_at_27_10_2020_13_16_[Default_Changelist]/Game$2.class b/.idea/shelf/Uncommitted_changes_before_Update_at_27_10_2020_13_16_[Default_Changelist]/Game$2.class new file mode 100644 index 00000000..d86ffe16 Binary files /dev/null and b/.idea/shelf/Uncommitted_changes_before_Update_at_27_10_2020_13_16_[Default_Changelist]/Game$2.class differ diff --git a/.idea/shelf/Uncommitted_changes_before_Update_at_27_10_2020_13_16_[Default_Changelist]/Game.class b/.idea/shelf/Uncommitted_changes_before_Update_at_27_10_2020_13_16_[Default_Changelist]/Game.class new file mode 100644 index 00000000..9431735a Binary files /dev/null and b/.idea/shelf/Uncommitted_changes_before_Update_at_27_10_2020_13_16_[Default_Changelist]/Game.class differ diff --git a/.idea/shelf/Uncommitted_changes_before_Update_at_27_10_2020_13_16_[Default_Changelist]/Projectile.class b/.idea/shelf/Uncommitted_changes_before_Update_at_27_10_2020_13_16_[Default_Changelist]/Projectile.class new file mode 100644 index 00000000..71137f11 Binary files /dev/null and b/.idea/shelf/Uncommitted_changes_before_Update_at_27_10_2020_13_16_[Default_Changelist]/Projectile.class differ diff --git a/.idea/shelf/Uncommitted_changes_before_Update_at_27_10_2020_13_16_[Default_Changelist]/Tank.class b/.idea/shelf/Uncommitted_changes_before_Update_at_27_10_2020_13_16_[Default_Changelist]/Tank.class new file mode 100644 index 00000000..9d21c428 Binary files /dev/null and b/.idea/shelf/Uncommitted_changes_before_Update_at_27_10_2020_13_16_[Default_Changelist]/Tank.class differ diff --git a/.idea/shelf/Uncommitted_changes_before_Update_at_27_10_2020_13_16_[Default_Changelist]/shelved.patch b/.idea/shelf/Uncommitted_changes_before_Update_at_27_10_2020_13_16_[Default_Changelist]/shelved.patch new file mode 100644 index 00000000..43dea1a1 --- /dev/null +++ b/.idea/shelf/Uncommitted_changes_before_Update_at_27_10_2020_13_16_[Default_Changelist]/shelved.patch @@ -0,0 +1,198 @@ +Index: .idea/workspace.xml +IDEA additional info: +Subsystem: com.intellij.openapi.diff.impl.patch.BaseRevisionTextPatchEP +<+>\r\n\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n 1602501096197\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n +Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP +<+>UTF-8 +=================================================================== +--- .idea/workspace.xml (revision cffb779d9ab14d103cd539b38aa49cdbcc188f89) ++++ .idea/workspace.xml (date 1603801005225) +@@ -2,20 +2,15 @@ + + + +- + +- + + + +- ++ + +- +- +- +- +- +- ++ ++ ++ + + + + ++ + + +@@ -42,7 +42,7 @@ + + + +- ++ + + + +@@ -74,6 +74,17 @@ + +- ++ + + + +@@ -111,58 +123,91 @@ + + + +- ++ ++ + ++ ++ 1603800135439 ++ ++ + +- ++ ++ ++ + +- ++ + + +- +- ++ ++ + + +- ++ + + + + +- ++ + + +- +- ++ ++ + + +- ++ ++ ++ ++ ++ + + + + +- ++ + + +- +- ++ ++ + + +- +- ++ ++ + + +- +- ++ ++ + + +- +- ++ ++ + + +- ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ + + + diff --git a/.idea/shelf/Uncommitted_changes_before_Update_at_27_10_2020_13_37_[Default_Changelist]/Game$1.class b/.idea/shelf/Uncommitted_changes_before_Update_at_27_10_2020_13_37_[Default_Changelist]/Game$1.class new file mode 100644 index 00000000..aee8b7b6 Binary files /dev/null and b/.idea/shelf/Uncommitted_changes_before_Update_at_27_10_2020_13_37_[Default_Changelist]/Game$1.class differ diff --git a/.idea/shelf/Uncommitted_changes_before_Update_at_27_10_2020_13_37_[Default_Changelist]/Game$2.class b/.idea/shelf/Uncommitted_changes_before_Update_at_27_10_2020_13_37_[Default_Changelist]/Game$2.class new file mode 100644 index 00000000..9c4f03c6 Binary files /dev/null and b/.idea/shelf/Uncommitted_changes_before_Update_at_27_10_2020_13_37_[Default_Changelist]/Game$2.class differ diff --git a/.idea/shelf/Uncommitted_changes_before_Update_at_27_10_2020_13_37_[Default_Changelist]/Game.class b/.idea/shelf/Uncommitted_changes_before_Update_at_27_10_2020_13_37_[Default_Changelist]/Game.class new file mode 100644 index 00000000..82e7017b Binary files /dev/null and b/.idea/shelf/Uncommitted_changes_before_Update_at_27_10_2020_13_37_[Default_Changelist]/Game.class differ diff --git a/.idea/shelf/Uncommitted_changes_before_Update_at_27_10_2020_13_37_[Default_Changelist]/Projectile.class b/.idea/shelf/Uncommitted_changes_before_Update_at_27_10_2020_13_37_[Default_Changelist]/Projectile.class new file mode 100644 index 00000000..71137f11 Binary files /dev/null and b/.idea/shelf/Uncommitted_changes_before_Update_at_27_10_2020_13_37_[Default_Changelist]/Projectile.class differ diff --git a/.idea/shelf/Uncommitted_changes_before_Update_at_27_10_2020_13_37_[Default_Changelist]/Tank.class b/.idea/shelf/Uncommitted_changes_before_Update_at_27_10_2020_13_37_[Default_Changelist]/Tank.class new file mode 100644 index 00000000..9d21c428 Binary files /dev/null and b/.idea/shelf/Uncommitted_changes_before_Update_at_27_10_2020_13_37_[Default_Changelist]/Tank.class differ diff --git a/.idea/shelf/Uncommitted_changes_before_Update_at_27_10_2020_13_37_[Default_Changelist]/shelved.patch b/.idea/shelf/Uncommitted_changes_before_Update_at_27_10_2020_13_37_[Default_Changelist]/shelved.patch new file mode 100644 index 00000000..42d49295 --- /dev/null +++ b/.idea/shelf/Uncommitted_changes_before_Update_at_27_10_2020_13_37_[Default_Changelist]/shelved.patch @@ -0,0 +1,198 @@ +Index: .idea/workspace.xml +IDEA additional info: +Subsystem: com.intellij.openapi.diff.impl.patch.BaseRevisionTextPatchEP +<+>\r\n\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n 1602501096197\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n +Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP +<+>UTF-8 +=================================================================== +--- .idea/workspace.xml (revision 618d105bccf119e5cf04f6fe46ab047eaf38f640) ++++ .idea/workspace.xml (date 1603802162584) +@@ -2,20 +2,15 @@ + + + +- + +- + + + +- ++ + +- +- +- +- +- +- ++ ++ ++ + + + + ++ + + +@@ -42,7 +42,7 @@ + + + +- ++ + + + +@@ -74,6 +74,17 @@ + +- ++ + + + +@@ -111,58 +123,91 @@ + + + +- ++ ++ + ++ ++ 1603800135439 ++ ++ + +- ++ ++ ++ + +- ++ + + +- +- ++ ++ + + +- ++ + + + + +- ++ + + +- +- ++ ++ + + +- ++ ++ ++ ++ ++ + + + + +- ++ + + +- +- ++ ++ + + +- +- ++ ++ + + +- +- ++ ++ + + +- +- ++ ++ + + +- ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ + + + diff --git a/.idea/uiDesigner.xml b/.idea/uiDesigner.xml new file mode 100644 index 00000000..e96534fb --- /dev/null +++ b/.idea/uiDesigner.xml @@ -0,0 +1,124 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 00000000..35eb1ddf --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/workspace.xml b/.idea/workspace.xml new file mode 100644 index 00000000..35497279 --- /dev/null +++ b/.idea/workspace.xml @@ -0,0 +1,228 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1602501096197 + + + 1603800135439 + + + 1603803783896 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 00000000..e373fdc3 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,84 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "type": "java", + "name": "CodeLens (Launch) - Server", + "request": "launch", + "mainClass": "src.com.company.src.com.company.Server", + "projectName": "Gruppe-306-PCSS_7455d736" + }, + { + "type": "java", + "name": "CodeLens (Launch) - ServerTestClient", + "request": "launch", + "mainClass": "company.ServerTestClient", + "projectName": "Gruppe-306-PCSS_34b6929c" + }, + { + "type": "java", + "name": "CodeLens (Launch) - Main", + "request": "launch", + "mainClass": "src.com.company.Main", + "projectName": "Gruppe-306-PCSS_ef11dab7" + }, + { + "type": "java", + "name": "CodeLens (Launch) - Server", + "request": "launch", + "mainClass": "src.com.company.Server", + "projectName": "Gruppe-306-PCSS_ef11dab7" + }, + { + "type": "java", + "name": "CodeLens (Launch) - Main", + "request": "launch", + "mainClass": "Main", + "projectName": "Gruppe-306-PCSS_7455d736" + }, + { + "type": "java", + "name": "CodeLens (Launch) - ServerTestClient", + "request": "launch", + "mainClass": "company.ServerTestClient", + "projectName": "Gruppe-306-PCSS_7226f30" + }, + { + "type": "java", + "name": "CodeLens (Launch) - ServerTestClient", + "request": "launch", + "mainClass": "ServerTestClient", + "projectName": "Gruppe-306-PCSS_7226f30" + }, + { + "type": "java", + "name": "CodeLens (Launch) - ServerTestClient", + "request": "launch", + "mainClass": "company.ServerTestClient", + "projectName": "Gruppe-306-PCSS_7455d736" + }, + { + "type": "java", + "name": "CodeLens (Launch) - ServerTestClient", + "request": "launch", + "mainClass": "ServerTestClient", + "projectName": "Gruppe-306-PCSS_7455d736" + }, + { + "type": "java", + "name": "CodeLens (Launch) - Main", + "request": "launch", + "mainClass": "src.com.company.Main", + "projectName": "Gruppe-306-PCSS_7455d736" + }, + { + "type": "java", + "name": "Debug (Launch) - Current File", + "request": "launch", + "mainClass": "${file}" + } + ] +} \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 00000000..2421e386 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,8 @@ +{ + "files.exclude": { + "**/.classpath": true, + "**/.project": true, + "**/.settings": true, + "**/.factorypath": true + } +} \ No newline at end of file diff --git a/Server/.idea/.gitignore b/Server/.idea/.gitignore new file mode 100644 index 00000000..7c0f099e --- /dev/null +++ b/Server/.idea/.gitignore @@ -0,0 +1,10 @@ +# Default ignored files +/workspace.xml +/description.html +/encodings.xml +/misc.xml +/modules.xml +/project-template.xml +/vcs.xml +/launch.json +/settings.json \ No newline at end of file diff --git a/Server/.idea/description.html b/Server/.idea/description.html new file mode 100644 index 00000000..db5f1295 --- /dev/null +++ b/Server/.idea/description.html @@ -0,0 +1 @@ +Simple Java application that includes a class with main() method \ No newline at end of file diff --git a/Server/.idea/encodings.xml b/Server/.idea/encodings.xml new file mode 100644 index 00000000..97626ba4 --- /dev/null +++ b/Server/.idea/encodings.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Server/.idea/misc.xml b/Server/.idea/misc.xml new file mode 100644 index 00000000..1386f2e1 --- /dev/null +++ b/Server/.idea/misc.xml @@ -0,0 +1,9 @@ + + + + + + + + \ No newline at end of file diff --git a/Server/.idea/modules.xml b/Server/.idea/modules.xml new file mode 100644 index 00000000..7ec00e1c --- /dev/null +++ b/Server/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/Server/.idea/project-template.xml b/Server/.idea/project-template.xml new file mode 100644 index 00000000..1f08b887 --- /dev/null +++ b/Server/.idea/project-template.xml @@ -0,0 +1,3 @@ + \ No newline at end of file diff --git a/Server/.idea/vcs.xml b/Server/.idea/vcs.xml new file mode 100644 index 00000000..6c0b8635 --- /dev/null +++ b/Server/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Server/.idea/workspace.xml b/Server/.idea/workspace.xml new file mode 100644 index 00000000..76f26ddc --- /dev/null +++ b/Server/.idea/workspace.xml @@ -0,0 +1,74 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1602241973712 + + + + + + + + + + + + \ No newline at end of file diff --git a/Server/src/com/company/src/com/company/Database.java b/Server/src/com/company/src/com/company/Database.java new file mode 100644 index 00000000..e2d2ac08 --- /dev/null +++ b/Server/src/com/company/src/com/company/Database.java @@ -0,0 +1,33 @@ +package src.com.company.src.com.company; + +import java.util.*; + +public class Database { + + private ListPlayerID = new ArrayList<>(); + private List lobbies = new ArrayList<>(); + + public List getPlayerList() { + return this.PlayerID; + } + + public void addPlayer(String player) { + PlayerID.add(player); + } + + public void removePlayer(String player){ + PlayerID.remove(PlayerID.indexOf(player)); + } + + public void addLobby (String lobbyName, String host, List players){ + LobbyDatabase l = new LobbyDatabase(lobbyName,host,players); + this.lobbies.add(l); + } + + public List getLobbies() { + return lobbies; + } + + + +} diff --git a/Server/src/com/company/src/com/company/LobbyDatabase.java b/Server/src/com/company/src/com/company/LobbyDatabase.java new file mode 100644 index 00000000..107a312a --- /dev/null +++ b/Server/src/com/company/src/com/company/LobbyDatabase.java @@ -0,0 +1,32 @@ +package src.com.company.src.com.company; + +import java.util.ArrayList; +import java.util.List; + +public class LobbyDatabase { + + String lobbyName; + String host; + List players; + + LobbyDatabase (String lobbyName, String host, List players) { + this.host = host; + this.lobbyName = lobbyName; + this.players = players; + } + + public String getHost() { + return host; + } + + public String getLobbyName() { + return lobbyName; + } + + public List getPlayers() { + return players; + } + + + +} diff --git a/Server/src/com/company/src/com/company/Server.java b/Server/src/com/company/src/com/company/Server.java new file mode 100644 index 00000000..ee1b2f89 --- /dev/null +++ b/Server/src/com/company/src/com/company/Server.java @@ -0,0 +1,72 @@ +package src.com.company.src.com.company; + +import java.io.IOException; +import java.net.ServerSocket; +import java.net.Socket; +import java.util.ArrayList; +import java.util.Date; +import java.util.Scanner; + +public class Server extends Thread { + private int port; + private ArrayList users; + private boolean lobby; + private ServerSocket serverSocket; + + public Server(int port) { + this.port = port; + lobby = true; + users = new ArrayList<>(); + } + + public static void main(String[] args) { + Scanner scan = new Scanner(System.in); + System.out.println("Connection established. "); + System.out.println("Enter Port: "); + int paPort = scan.nextInt(); + Server server = new Server(paPort); + scan.close(); + server.initiateServer(); + } + + public void initiateServer() { + try { + + serverSocket = new ServerSocket(port); + System.out.println("Server started at " + new Date()); + + + while (lobby) { + Socket socket = serverSocket.accept(); + UserThread newUser = new UserThread(this, socket); + users.add(newUser); + newUser.start(); + System.out.println(users.size()); + } + + } catch (IOException e) { + System.out.println("Unable to start server IOException"); + e.printStackTrace(); + } + } + + public ArrayList getUsers() { + return users; + } + + public void removeUser(UserThread ut, String userName) { + users.remove(ut); + System.out.println(userName + " left the server"); + } + + public void sendToAll(String message, UserThread ut) { + for (UserThread userThread : users) { + if (userThread != ut) + userThread.sendMessage(message); + } + } + + public ServerSocket getServerSocket() { + return serverSocket; + } +} diff --git a/Server/src/com/company/src/com/company/UserThread.java b/Server/src/com/company/src/com/company/UserThread.java new file mode 100644 index 00000000..f803b0d9 --- /dev/null +++ b/Server/src/com/company/src/com/company/UserThread.java @@ -0,0 +1,93 @@ +package src.com.company.src.com.company; + +import java.io.DataInputStream; +import java.io.DataOutputStream; +import java.io.IOException; +import java.net.Socket; +import java.util.ArrayList; +import java.util.List; + +public class UserThread extends Thread { + + private Server server; + private Socket socket; + private String playerID; + private DataOutputStream output; + private DataInputStream input; + public static Database database = new Database(); + + public UserThread(Server server, Socket socket) { + this.server = server; + this.socket = socket; + + } + + @Override + public void run() { + try { + input = new DataInputStream(socket.getInputStream()); + output = new DataOutputStream(socket.getOutputStream()); + playerID = input.readUTF(); + System.out.println(playerID + " joined the server"); + database.addPlayer(playerID); + + while(true){ + String commandType = input.readUTF(); + if(commandType.equals("sendSubLobby")){ + System.out.println(playerID + "creating lobby "); + recieveSubLobby(); + System.out.println(playerID + "'s lobby created"); + } + if(commandType.equals("requestLobbyList")){ + System.out.println("Sending lobby list to " + playerID); + sendSubLobby(); + } + + + + } + + } catch (IOException e) { + e.printStackTrace(); + } + } + public void recieveSubLobby() throws IOException { + String lobbyName = input.readUTF(); + String host = input.readUTF(); + + // int len = input.readInt(); + List players = new ArrayList<>(); + players.add(host); + database.addLobby(lobbyName, host, players); + // for(int i = 0; i lobbies = new ArrayList<>(); + lobbies = database.getLobbies(); + output.writeInt(lobbies.size()); + System.out.println("lobby size: " + lobbies.size()); + for (int i = 0; i< lobbies.size(); i++){ + output.writeUTF(lobbies.get(i).getLobbyName()); + output.writeUTF(lobbies.get(i).getHost()); + output.writeInt(lobbies.get(i).getPlayers().size()); + for (int j = 0; j< lobbies.get(i).getPlayers().size(); j++){ + output.writeUTF(lobbies.get(i).getPlayers().get(j)); + } + } + } + + + public void sendMessage(String message) { + try { + output.writeUTF(message); + output.flush(); + } + catch (IOException e) { + e.printStackTrace(); + } + } +} \ No newline at end of file diff --git a/ServerTestClient/.idea/.gitignore b/ServerTestClient/.idea/.gitignore new file mode 100644 index 00000000..5c98b428 --- /dev/null +++ b/ServerTestClient/.idea/.gitignore @@ -0,0 +1,2 @@ +# Default ignored files +/workspace.xml \ No newline at end of file diff --git a/ServerTestClient/.idea/description.html b/ServerTestClient/.idea/description.html new file mode 100644 index 00000000..db5f1295 --- /dev/null +++ b/ServerTestClient/.idea/description.html @@ -0,0 +1 @@ +Simple Java application that includes a class with main() method \ No newline at end of file diff --git a/ServerTestClient/.idea/encodings.xml b/ServerTestClient/.idea/encodings.xml new file mode 100644 index 00000000..97626ba4 --- /dev/null +++ b/ServerTestClient/.idea/encodings.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/ServerTestClient/.idea/misc.xml b/ServerTestClient/.idea/misc.xml new file mode 100644 index 00000000..68801dd1 --- /dev/null +++ b/ServerTestClient/.idea/misc.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/ServerTestClient/.idea/modules.xml b/ServerTestClient/.idea/modules.xml new file mode 100644 index 00000000..ef947ba3 --- /dev/null +++ b/ServerTestClient/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/ServerTestClient/.idea/project-template.xml b/ServerTestClient/.idea/project-template.xml new file mode 100644 index 00000000..1f08b887 --- /dev/null +++ b/ServerTestClient/.idea/project-template.xml @@ -0,0 +1,3 @@ + \ No newline at end of file diff --git a/ServerTestClient/.idea/vcs.xml b/ServerTestClient/.idea/vcs.xml new file mode 100644 index 00000000..6c0b8635 --- /dev/null +++ b/ServerTestClient/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/ServerTestClient/.idea/workspace.xml b/ServerTestClient/.idea/workspace.xml new file mode 100644 index 00000000..9aa202cb --- /dev/null +++ b/ServerTestClient/.idea/workspace.xml @@ -0,0 +1,60 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1602242737493 + + + + + + \ No newline at end of file diff --git a/ServerTestClient/src/com/company/ServerTestClient.java b/ServerTestClient/src/com/company/ServerTestClient.java new file mode 100644 index 00000000..0f00cc09 --- /dev/null +++ b/ServerTestClient/src/com/company/ServerTestClient.java @@ -0,0 +1,47 @@ +package company; +import java.util.Scanner; +import java.net.*; +import java.io.*; + + + +public class ServerTestClient { + + public static void main(String[] args) { + DataOutputStream toServer = null; + DataInputStream fromServer = null; + int port = 8000; + // ipv4 address for server + String host = "192.168.43.236"; + boolean Continue = true; + Socket socket = null; + + + try { + socket = new Socket(host, port); + System.out.println("Connection to server established "); + toServer = new DataOutputStream(socket.getOutputStream()); + fromServer = new DataInputStream(socket.getInputStream()); + + while (Continue == true) { + + double testData = 1; + System.out.println(testData); + toServer.writeDouble(testData); + + testData = fromServer.readDouble(); + System.out.println(testData); + + + } + } + + catch (IOException e) { + e.printStackTrace(); + } + + + + } +} + diff --git a/Tank game - Client/.idea/.gitignore b/Tank game - Client/.idea/.gitignore new file mode 100644 index 00000000..062a84f5 --- /dev/null +++ b/Tank game - Client/.idea/.gitignore @@ -0,0 +1,9 @@ +# Default ignored files +/workspace.xml +/misc.xml +/modules.xml +/uiDesigner.xml +/vcs.xml +/workspace.xml +/labraries.* +/libraries diff --git a/Tank game - Client/.idea/.name b/Tank game - Client/.idea/.name new file mode 100644 index 00000000..3a35b036 --- /dev/null +++ b/Tank game - Client/.idea/.name @@ -0,0 +1 @@ +Datasender.java \ No newline at end of file diff --git a/Tank game - Client/.idea/libraries/lib.xml b/Tank game - Client/.idea/libraries/lib.xml new file mode 100644 index 00000000..59fbaf73 --- /dev/null +++ b/Tank game - Client/.idea/libraries/lib.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/Tank game - Client/.idea/misc.xml b/Tank game - Client/.idea/misc.xml new file mode 100644 index 00000000..5217e29a --- /dev/null +++ b/Tank game - Client/.idea/misc.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Tank game - Client/.idea/modules.xml b/Tank game - Client/.idea/modules.xml new file mode 100644 index 00000000..03ae1cf6 --- /dev/null +++ b/Tank game - Client/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/Tank game - Client/.idea/uiDesigner.xml b/Tank game - Client/.idea/uiDesigner.xml new file mode 100644 index 00000000..e96534fb --- /dev/null +++ b/Tank game - Client/.idea/uiDesigner.xml @@ -0,0 +1,124 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Tank game - Client/.idea/vcs.xml b/Tank game - Client/.idea/vcs.xml new file mode 100644 index 00000000..6c0b8635 --- /dev/null +++ b/Tank game - Client/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Tank game - Client/.idea/workspace.xml b/Tank game - Client/.idea/workspace.xml new file mode 100644 index 00000000..24dd8dd2 --- /dev/null +++ b/Tank game - Client/.idea/workspace.xml @@ -0,0 +1,230 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1601469582604 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Tank game - Client/Tank game - Client.iml b/Tank game - Client/Tank game - Client.iml new file mode 100644 index 00000000..fb8e8667 --- /dev/null +++ b/Tank game - Client/Tank game - Client.iml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/Tank game - Client/out/production/Gruppe-306-PCSS/.idea/.gitignore b/Tank game - Client/out/production/Gruppe-306-PCSS/.idea/.gitignore new file mode 100644 index 00000000..d3c399ae --- /dev/null +++ b/Tank game - Client/out/production/Gruppe-306-PCSS/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Datasource local storage ignored files +/../../../../../../../../../:\Users\atlen\Documents\GitHub\Gruppe-306-PCSS\Tank game - Client\src\.idea/dataSources/ +/dataSources.local.xml +# Editor-based HTTP Client requests +/httpRequests/ diff --git a/Tank game - Client/out/production/Gruppe-306-PCSS/.idea/misc.xml b/Tank game - Client/out/production/Gruppe-306-PCSS/.idea/misc.xml new file mode 100644 index 00000000..37e641e9 --- /dev/null +++ b/Tank game - Client/out/production/Gruppe-306-PCSS/.idea/misc.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Tank game - Client/out/production/Gruppe-306-PCSS/.idea/modules.xml b/Tank game - Client/out/production/Gruppe-306-PCSS/.idea/modules.xml new file mode 100644 index 00000000..3dc5734c --- /dev/null +++ b/Tank game - Client/out/production/Gruppe-306-PCSS/.idea/modules.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/Tank game - Client/out/production/Gruppe-306-PCSS/.idea/src.iml b/Tank game - Client/out/production/Gruppe-306-PCSS/.idea/src.iml new file mode 100644 index 00000000..d6ebd480 --- /dev/null +++ b/Tank game - Client/out/production/Gruppe-306-PCSS/.idea/src.iml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/Tank game - Client/out/production/Gruppe-306-PCSS/.idea/vcs.xml b/Tank game - Client/out/production/Gruppe-306-PCSS/.idea/vcs.xml new file mode 100644 index 00000000..b2bdec2d --- /dev/null +++ b/Tank game - Client/out/production/Gruppe-306-PCSS/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Tank game - Client/out/production/Gruppe-306-PCSS/Collision.class b/Tank game - Client/out/production/Gruppe-306-PCSS/Collision.class new file mode 100644 index 00000000..2bdf3c6a Binary files /dev/null and b/Tank game - Client/out/production/Gruppe-306-PCSS/Collision.class differ diff --git a/Tank game - Client/out/production/Gruppe-306-PCSS/Datasender.class b/Tank game - Client/out/production/Gruppe-306-PCSS/Datasender.class new file mode 100644 index 00000000..c22a1b88 Binary files /dev/null and b/Tank game - Client/out/production/Gruppe-306-PCSS/Datasender.class differ diff --git a/Tank game - Client/out/production/Gruppe-306-PCSS/Game$1.class b/Tank game - Client/out/production/Gruppe-306-PCSS/Game$1.class new file mode 100644 index 00000000..ee9d7e14 Binary files /dev/null and b/Tank game - Client/out/production/Gruppe-306-PCSS/Game$1.class differ diff --git a/Tank game - Client/out/production/Gruppe-306-PCSS/Game$2.class b/Tank game - Client/out/production/Gruppe-306-PCSS/Game$2.class new file mode 100644 index 00000000..47f805e2 Binary files /dev/null and b/Tank game - Client/out/production/Gruppe-306-PCSS/Game$2.class differ diff --git a/Tank game - Client/out/production/Gruppe-306-PCSS/Game.class b/Tank game - Client/out/production/Gruppe-306-PCSS/Game.class new file mode 100644 index 00000000..1f33ce9b Binary files /dev/null and b/Tank game - Client/out/production/Gruppe-306-PCSS/Game.class differ diff --git a/Tank game - Client/out/production/Gruppe-306-PCSS/GameStartChecker.class b/Tank game - Client/out/production/Gruppe-306-PCSS/GameStartChecker.class new file mode 100644 index 00000000..7e0b2c83 Binary files /dev/null and b/Tank game - Client/out/production/Gruppe-306-PCSS/GameStartChecker.class differ diff --git a/Tank game - Client/out/production/Gruppe-306-PCSS/Lobby.class b/Tank game - Client/out/production/Gruppe-306-PCSS/Lobby.class new file mode 100644 index 00000000..2cd2b0f2 Binary files /dev/null and b/Tank game - Client/out/production/Gruppe-306-PCSS/Lobby.class differ diff --git a/Tank game - Client/out/production/Gruppe-306-PCSS/LobbySender.class b/Tank game - Client/out/production/Gruppe-306-PCSS/LobbySender.class new file mode 100644 index 00000000..d7a0e16a Binary files /dev/null and b/Tank game - Client/out/production/Gruppe-306-PCSS/LobbySender.class differ diff --git a/Tank game - Client/out/production/Gruppe-306-PCSS/Map.class b/Tank game - Client/out/production/Gruppe-306-PCSS/Map.class new file mode 100644 index 00000000..99a11eed Binary files /dev/null and b/Tank game - Client/out/production/Gruppe-306-PCSS/Map.class differ diff --git a/Tank game - Client/out/production/Gruppe-306-PCSS/NewMap.class b/Tank game - Client/out/production/Gruppe-306-PCSS/NewMap.class new file mode 100644 index 00000000..7ad33c3c Binary files /dev/null and b/Tank game - Client/out/production/Gruppe-306-PCSS/NewMap.class differ diff --git a/Tank game - Client/out/production/Gruppe-306-PCSS/Projectile.class b/Tank game - Client/out/production/Gruppe-306-PCSS/Projectile.class new file mode 100644 index 00000000..f4685916 Binary files /dev/null and b/Tank game - Client/out/production/Gruppe-306-PCSS/Projectile.class differ diff --git a/Tank game - Client/out/production/Gruppe-306-PCSS/SubLobby.class b/Tank game - Client/out/production/Gruppe-306-PCSS/SubLobby.class new file mode 100644 index 00000000..05b14117 Binary files /dev/null and b/Tank game - Client/out/production/Gruppe-306-PCSS/SubLobby.class differ diff --git a/Tank game - Client/out/production/Gruppe-306-PCSS/TODO list b/Tank game - Client/out/production/Gruppe-306-PCSS/TODO list new file mode 100644 index 00000000..0e175e6d --- /dev/null +++ b/Tank game - Client/out/production/Gruppe-306-PCSS/TODO list @@ -0,0 +1,25 @@ +Fjern bullets +DONE> efter timer +DONE> efter ramt tank + +Lav colission +> tank --> væg +> tank --> tank +DONE> bullet --> tank + +Map + +Lobby + +Scoreboard + +End game screen + +List af ting vi skal sende til serveren + +Liste vi skal bruge fra serveren +> array med tanks +> tank ID + +PlayerID +> synkronisering mellem classes \ No newline at end of file diff --git a/Tank game - Client/out/production/Gruppe-306-PCSS/Tank game - Client.iml b/Tank game - Client/out/production/Gruppe-306-PCSS/Tank game - Client.iml new file mode 100644 index 00000000..b107a2dd --- /dev/null +++ b/Tank game - Client/out/production/Gruppe-306-PCSS/Tank game - Client.iml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/Tank game - Client/out/production/Gruppe-306-PCSS/Tank.class b/Tank game - Client/out/production/Gruppe-306-PCSS/Tank.class new file mode 100644 index 00000000..9c68233e Binary files /dev/null and b/Tank game - Client/out/production/Gruppe-306-PCSS/Tank.class differ diff --git a/Tank game - Client/out/production/Gruppe-306-PCSS/update b/Tank game - Client/out/production/Gruppe-306-PCSS/update new file mode 100644 index 00000000..578abd17 --- /dev/null +++ b/Tank game - Client/out/production/Gruppe-306-PCSS/update @@ -0,0 +1,29 @@ + private void update() { + sprites().forEach(s -> { //handles what happens to the sprites/bullets + switch (s.type) { + /*case "enemybullet": + if (s.getBoundsInParent().intersects(player.getBoundsInParent())) { + player.dead = true; + s.dead = true; + } + break; + */ + + case "playerbullet": + final int angle = player.getAngle(); + s.moveBullet(angle); + sprites().stream().filter(e -> e.type.equals("enemy")).forEach(enemy -> { + if (s.getBoundsInParent().intersects(enemy.getBoundsInParent())) { + enemy.dead = true; + s.dead = true; + } + }); + break; + } + }); + + root.getChildren().removeIf(n -> { + Sprite s = (Sprite) n; + return s.dead; + }); + } \ No newline at end of file diff --git a/Tank game - Client/out/production/Tank game - Client/.idea/.gitignore b/Tank game - Client/out/production/Tank game - Client/.idea/.gitignore new file mode 100644 index 00000000..d3c399ae --- /dev/null +++ b/Tank game - Client/out/production/Tank game - Client/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Datasource local storage ignored files +/../../../../../../../../../:\Users\atlen\Documents\GitHub\Gruppe-306-PCSS\Tank game - Client\src\.idea/dataSources/ +/dataSources.local.xml +# Editor-based HTTP Client requests +/httpRequests/ diff --git a/Tank game - Client/out/production/Tank game - Client/.idea/misc.xml b/Tank game - Client/out/production/Tank game - Client/.idea/misc.xml new file mode 100644 index 00000000..37e641e9 --- /dev/null +++ b/Tank game - Client/out/production/Tank game - Client/.idea/misc.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Tank game - Client/out/production/Tank game - Client/.idea/modules.xml b/Tank game - Client/out/production/Tank game - Client/.idea/modules.xml new file mode 100644 index 00000000..3dc5734c --- /dev/null +++ b/Tank game - Client/out/production/Tank game - Client/.idea/modules.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/Tank game - Client/out/production/Tank game - Client/.idea/src.iml b/Tank game - Client/out/production/Tank game - Client/.idea/src.iml new file mode 100644 index 00000000..d6ebd480 --- /dev/null +++ b/Tank game - Client/out/production/Tank game - Client/.idea/src.iml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/Tank game - Client/out/production/Tank game - Client/.idea/vcs.xml b/Tank game - Client/out/production/Tank game - Client/.idea/vcs.xml new file mode 100644 index 00000000..b2bdec2d --- /dev/null +++ b/Tank game - Client/out/production/Tank game - Client/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Tank game - Client/out/production/Tank game - Client/Collision.class b/Tank game - Client/out/production/Tank game - Client/Collision.class new file mode 100644 index 00000000..2bdf3c6a Binary files /dev/null and b/Tank game - Client/out/production/Tank game - Client/Collision.class differ diff --git a/Tank game - Client/out/production/Tank game - Client/Datasender.class b/Tank game - Client/out/production/Tank game - Client/Datasender.class new file mode 100644 index 00000000..c22a1b88 Binary files /dev/null and b/Tank game - Client/out/production/Tank game - Client/Datasender.class differ diff --git a/Tank game - Client/out/production/Tank game - Client/Game$1.class b/Tank game - Client/out/production/Tank game - Client/Game$1.class new file mode 100644 index 00000000..ee9d7e14 Binary files /dev/null and b/Tank game - Client/out/production/Tank game - Client/Game$1.class differ diff --git a/Tank game - Client/out/production/Tank game - Client/Game$2.class b/Tank game - Client/out/production/Tank game - Client/Game$2.class new file mode 100644 index 00000000..d049587c Binary files /dev/null and b/Tank game - Client/out/production/Tank game - Client/Game$2.class differ diff --git a/Tank game - Client/out/production/Tank game - Client/Game.class b/Tank game - Client/out/production/Tank game - Client/Game.class new file mode 100644 index 00000000..3fc51485 Binary files /dev/null and b/Tank game - Client/out/production/Tank game - Client/Game.class differ diff --git a/Tank game - Client/out/production/Tank game - Client/GameStartChecker.class b/Tank game - Client/out/production/Tank game - Client/GameStartChecker.class new file mode 100644 index 00000000..7e0b2c83 Binary files /dev/null and b/Tank game - Client/out/production/Tank game - Client/GameStartChecker.class differ diff --git a/Tank game - Client/out/production/Tank game - Client/LobbySender.class b/Tank game - Client/out/production/Tank game - Client/LobbySender.class new file mode 100644 index 00000000..d7a0e16a Binary files /dev/null and b/Tank game - Client/out/production/Tank game - Client/LobbySender.class differ diff --git a/Tank game - Client/out/production/Tank game - Client/Map.class b/Tank game - Client/out/production/Tank game - Client/Map.class new file mode 100644 index 00000000..99a11eed Binary files /dev/null and b/Tank game - Client/out/production/Tank game - Client/Map.class differ diff --git a/Tank game - Client/out/production/Tank game - Client/NewMap.class b/Tank game - Client/out/production/Tank game - Client/NewMap.class new file mode 100644 index 00000000..7ad33c3c Binary files /dev/null and b/Tank game - Client/out/production/Tank game - Client/NewMap.class differ diff --git a/Tank game - Client/out/production/Tank game - Client/Projectile.class b/Tank game - Client/out/production/Tank game - Client/Projectile.class new file mode 100644 index 00000000..f4685916 Binary files /dev/null and b/Tank game - Client/out/production/Tank game - Client/Projectile.class differ diff --git a/Tank game - Client/out/production/Tank game - Client/SubLobby.class b/Tank game - Client/out/production/Tank game - Client/SubLobby.class new file mode 100644 index 00000000..69f58869 Binary files /dev/null and b/Tank game - Client/out/production/Tank game - Client/SubLobby.class differ diff --git a/Tank game - Client/out/production/Tank game - Client/TODO list b/Tank game - Client/out/production/Tank game - Client/TODO list new file mode 100644 index 00000000..0e175e6d --- /dev/null +++ b/Tank game - Client/out/production/Tank game - Client/TODO list @@ -0,0 +1,25 @@ +Fjern bullets +DONE> efter timer +DONE> efter ramt tank + +Lav colission +> tank --> væg +> tank --> tank +DONE> bullet --> tank + +Map + +Lobby + +Scoreboard + +End game screen + +List af ting vi skal sende til serveren + +Liste vi skal bruge fra serveren +> array med tanks +> tank ID + +PlayerID +> synkronisering mellem classes \ No newline at end of file diff --git a/Tank game - Client/out/production/Tank game - Client/Tank game - Client.iml b/Tank game - Client/out/production/Tank game - Client/Tank game - Client.iml new file mode 100644 index 00000000..b107a2dd --- /dev/null +++ b/Tank game - Client/out/production/Tank game - Client/Tank game - Client.iml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/Tank game - Client/out/production/Tank game - Client/Tank.class b/Tank game - Client/out/production/Tank game - Client/Tank.class new file mode 100644 index 00000000..a7ee8a81 Binary files /dev/null and b/Tank game - Client/out/production/Tank game - Client/Tank.class differ diff --git a/Tank game - Client/out/production/Tank game - Client/update b/Tank game - Client/out/production/Tank game - Client/update new file mode 100644 index 00000000..578abd17 --- /dev/null +++ b/Tank game - Client/out/production/Tank game - Client/update @@ -0,0 +1,29 @@ + private void update() { + sprites().forEach(s -> { //handles what happens to the sprites/bullets + switch (s.type) { + /*case "enemybullet": + if (s.getBoundsInParent().intersects(player.getBoundsInParent())) { + player.dead = true; + s.dead = true; + } + break; + */ + + case "playerbullet": + final int angle = player.getAngle(); + s.moveBullet(angle); + sprites().stream().filter(e -> e.type.equals("enemy")).forEach(enemy -> { + if (s.getBoundsInParent().intersects(enemy.getBoundsInParent())) { + enemy.dead = true; + s.dead = true; + } + }); + break; + } + }); + + root.getChildren().removeIf(n -> { + Sprite s = (Sprite) n; + return s.dead; + }); + } \ No newline at end of file diff --git a/Tank game - Client/src/.idea/.gitignore b/Tank game - Client/src/.idea/.gitignore new file mode 100644 index 00000000..d3c399ae --- /dev/null +++ b/Tank game - Client/src/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Datasource local storage ignored files +/../../../../../../../../../:\Users\atlen\Documents\GitHub\Gruppe-306-PCSS\Tank game - Client\src\.idea/dataSources/ +/dataSources.local.xml +# Editor-based HTTP Client requests +/httpRequests/ diff --git a/Tank game - Client/src/.idea/misc.xml b/Tank game - Client/src/.idea/misc.xml new file mode 100644 index 00000000..37e641e9 --- /dev/null +++ b/Tank game - Client/src/.idea/misc.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Tank game - Client/src/.idea/modules.xml b/Tank game - Client/src/.idea/modules.xml new file mode 100644 index 00000000..3dc5734c --- /dev/null +++ b/Tank game - Client/src/.idea/modules.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/Tank game - Client/src/.idea/src.iml b/Tank game - Client/src/.idea/src.iml new file mode 100644 index 00000000..d6ebd480 --- /dev/null +++ b/Tank game - Client/src/.idea/src.iml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/Tank game - Client/src/.idea/vcs.xml b/Tank game - Client/src/.idea/vcs.xml new file mode 100644 index 00000000..b2bdec2d --- /dev/null +++ b/Tank game - Client/src/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Tank game - Client/src/Collision.java b/Tank game - Client/src/Collision.java new file mode 100644 index 00000000..b5606e75 --- /dev/null +++ b/Tank game - Client/src/Collision.java @@ -0,0 +1,5 @@ +public class Collision { + + + +} diff --git a/Tank game - Client/src/Datasender.java b/Tank game - Client/src/Datasender.java new file mode 100644 index 00000000..5409ca16 --- /dev/null +++ b/Tank game - Client/src/Datasender.java @@ -0,0 +1,45 @@ +import java.util.Scanner; +import java.net.*; +import java.io.*; + + +public class Datasender { + DataOutputStream toServer = null; + DataInputStream fromServer = null; + int port = 8000; + // ipv4 address for server + String host = "192.168.43.236"; + boolean Continue = true; + Socket socket = null; + String playerID; + + Datasender(String playerID) { + try { + socket = new Socket(host, port); + System.out.println("Connection to server established "); + toServer = new DataOutputStream(socket.getOutputStream()); + fromServer = new DataInputStream(socket.getInputStream()); + this.playerID = playerID; + } catch (IOException e) { + e.printStackTrace(); + } + } + + + + public void setID(String playerID){ + this.playerID = playerID; + } + + void gameUpdate(){ + + } + + void sendXpos(){ + + } + +} + + + diff --git a/Tank game - Client/src/Game.java b/Tank game - Client/src/Game.java new file mode 100644 index 00000000..8c0dece9 --- /dev/null +++ b/Tank game - Client/src/Game.java @@ -0,0 +1,203 @@ +import javafx.animation.AnimationTimer; +import javafx.application.Application; +import javafx.scene.Parent; +import javafx.scene.Scene; +import javafx.scene.layout.Pane; +import javafx.scene.paint.Color; +import javafx.stage.Stage; + +import java.io.InputStream; +import java.util.ArrayList; +import java.util.List; + + +public class Game extends Application { + + Projectile[] projectiles; + + InputStream in = LobbySender.getFromServer(); + + //movement booleans + boolean left = false; + boolean right = false; + boolean forward = false; + boolean backward = false; + + + private Pane root = new Pane(); //initializes a Pane called root + + //size of the window + int width = 1200; + int height = 700; + + int wallWidth = 10; + + String playerID; + + private Tank player = new Tank(300, 300, 70, 40, playerID, Color.BLUE); + private Tank player2 = new Tank(100, 100, 70, 40, "2", Color.BISQUE); + Tank[] tanks = {player, player2};//puts the tanks into an array + //private List tank = new ArrayList(); + + + //map + private Map top = new Map(0, 0, 1200, wallWidth); + private Map bund = new Map(0, height - wallWidth, 1200, wallWidth); + private Map hoejre = new Map(width - wallWidth, 0, wallWidth, height); + private Map venstre = new Map(0, 0, wallWidth, height); + private Map map1 = new Map(200, 100, width / 2, wallWidth); + Map[] maps = {top, bund, venstre, hoejre, map1}; + + + + + private Parent createContent() { //creates the "draw" function - creates a Parent and returns it + root.setPrefSize(width, height); //sets width and height of window + + for(int i = 0; i< tanks.length; i++){ //makes the tanks + if(tanks[i] != null) { + root.getChildren().add(tanks[i]); + } + } + + for (int i = 0; i < maps.length; i++) { + root.getChildren().add(maps[i]); + } + + AnimationTimer timer = new AnimationTimer() { //everything in this is called each frame + @Override + public void handle(long now) { + update(); + } + }; + timer.start(); //starts the animationtimer + return root; //returns the root + } + + public void update() {//function where everything that happens every frame is called + //moves ALL bullets on the map + for (int i = 0; i < projectiles.length; i++) { + if (projectiles[i] != null) { //only does this function if there are bullets in the array + for (int j = 0; j < maps.length; j++) { + projectiles[i].moveBullet(maps[j]);//moves bullets + } + + //removes a tank if hit + if (projectiles[i].collision(tanks) != null) {//only does this if there is a hit tank + + Tank tank = projectiles[i].collision(tanks); + if (tank.getDead() == false) { + root.getChildren().remove(tank); + root.getChildren().remove(projectiles[i]);//removes the bullet visually + projectiles[i] = null;//removes the bullets from the array + } + tank.setDead(); + //root.getChildren().remove(projectiles[i].collision(tanks));//removes the tank visually + + + } + } + } + + //checks the lifespan and removes bullet if it is over a threshold + int threshold = 3000; //threshold - the bullets are removed after 300 frames + for (int i = 0; i < projectiles.length; i++) { + if (projectiles[i] != null && projectiles[i].getLifespan() >= threshold) { //only does this if there are bullets on the map and if one have been alive for 300 frames + root.getChildren().remove(projectiles[i]); //removes the projectile child + projectiles[i] = null; //removes projectile from array. + } + } +/* + if (left) { //moves if the boolean is true, this is smoother than having the move in the start function + player.rotateLeft(); + if (player.isColliding(maps)){ + player.rotateRight(); + + } + } + if (right) { + player.rotateRight(); + if (player.isColliding(maps)){ + player.rotateLeft(); + } + } + if (forward) { + player.moveForward(); + if (player.isColliding(maps)){ + player.moveBackward(); + + } + } + if (backward) { + player.moveBackward(); + if (player.isColliding(maps)){ + player.moveForward(); + + } + } + */ + + } + + + public void start(Stage stage) throws Exception { + Scene scene = new Scene(createContent()); //creates a scene with the root createContent as input + projectiles = player.getProjectiles(); //initializes the projectile array + Parameters para = getParameters(); + List list = para.getRaw(); + playerID = list.get(0); + System.out.println(list.get(0)); + + + //sets booleans to false if key is released + scene.setOnKeyReleased(e -> { + switch (e.getCode()) { + case LEFT: + left = false; + break; + case RIGHT: + right = false; + break; + case UP: + forward = false; + break; + case DOWN: + backward = false; + break; + } + }); + + //sets booleans to true if key is pressed + scene.setOnKeyPressed(e -> { + switch (e.getCode()) { + case LEFT: + left = true; + break; + case RIGHT: + right = true; + break; + case UP: + forward = true; + break; + case DOWN: + backward = true; + break; + case SPACE: + Projectile p = player.shoot(); + projectiles = player.getProjectiles(); + if (p != null) { + root.getChildren().add(p); + } + break; + } + }); + stage.setScene(scene);//creates a stage using the scene that uses the root + stage.show(); + } + + + + public static void main(String[] args) { + launch(args); + } +} diff --git a/Tank game - Client/src/GameStartChecker.java b/Tank game - Client/src/GameStartChecker.java new file mode 100644 index 00000000..1c432a43 --- /dev/null +++ b/Tank game - Client/src/GameStartChecker.java @@ -0,0 +1,54 @@ +import java.io.DataInputStream; +import java.io.DataOutputStream; +import java.io.IOException; +import java.sql.Struct; + +public class GameStartChecker extends Thread{ + private DataOutputStream toServer ; + private DataInputStream fromServer ; + + @Override + public void run() { + super.run(); + while(true) { + try { + toServer = LobbySender.getToServer(); + fromServer = LobbySender.getFromServer(); + + boolean runGame = false; + while (runGame != true ) { + if(gameStart() == true){ + + + + + + runGame =true; + } + + } + + + + } catch (IOException e) { + e.printStackTrace(); + } + + } + + + } + + @Override + public synchronized void start() { + super.start(); + } + + public boolean gameStart() throws IOException { + boolean b = fromServer.readBoolean(); + if (b){ + return true; + } + return false; + } +} diff --git a/Tank game - Client/src/Lobby.java b/Tank game - Client/src/Lobby.java new file mode 100644 index 00000000..e6582063 --- /dev/null +++ b/Tank game - Client/src/Lobby.java @@ -0,0 +1,255 @@ +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; +import java.util.Scanner; +import java.util.concurrent.atomic.AtomicReference; + +public class Lobby{ + + // private ListactiveGameName = new ArrayList(); + private List subLobbies = new ArrayList(); + public static List players = new ArrayList<>(); + + private String playerID; + private boolean isHost; + private String currentLobby; + private LobbySender sender; + + Scanner scanner = new Scanner(System.in); + + + Lobby() throws IOException { + + + System.out.println("Welcome to TANK the game!"); + + + + System.out.println("What is your name?"); + String id = scanner.nextLine(); + this.playerID = id; + sender = new LobbySender(id); + sender.setPlayerID(id); + sender.sendPlayerID(); + options(); + } + + public String PlayerID(){ + return playerID; + } + + + + void createLobby(String code) throws IOException { + SubLobby subLobby = new SubLobby(code, this.playerID); + this.subLobbies.add(subLobby); + sender.sendSubLobby(subLobby); + } + + + void updateLobbies(List s) throws IOException{ + for(int i = 0; i < s.size(); i++) { + if(subLobbies.size() == 0){ + subLobbies.add(s.get(i)); + System.out.println("New lobby found!: "+s.get(i).getLobbyName()); + break; + } + for (int j = 0; j newPlayers = sender.updatePlayers(this.currentLobby); + + for(int i = 0; i < subLobbies.size(); i++) { + if(subLobbies.get(i).getLobbyName().equals(this.currentLobby)){ + subLobbies.get(i).setPlayers(newPlayers); + + } + } + } + + void hostOptions(String lobbyName) { + System.out.println("Write \"ready\" if you are ready to start the game, or write \"list\" to see player list."); + System.out.println("Write \"exit\" to leave lobby"); + + try { + String input = scanner.nextLine(); + if (input.equals("ready")) { + readyCheck(); + //startGame(lobbyName); //Start ny instance af et game! + } else if (input.equals("list")) { + updatePlayers(); + for (int i = 0; i < subLobbies.size(); i++) { + if (subLobbies.get(i).getLobbyName().equals(lobbyName)) { + subLobbies.get(i).printPlayers(); + } + } + + + hostOptions(lobbyName); + } else if (input.equals("exit")) { + removeFromLobby(lobbyName); + } else { + System.out.println("Unknown input, try again"); + hostOptions(lobbyName); + } + } catch (Exception e) { + System.out.println(e); + System.out.println("Unknown input, try again"); + hostOptions(lobbyName); + } + + } + + void options() { + System.out.println("Write \"create\" if you want to create a new game, or write \"join\" to see a list of available games"); + String option = scanner.nextLine(); + try { + if (option.equals("create")) { + System.out.println("Creating Lobby. What should the lobby be named?"); + String lobbyName = scanner.nextLine(); + createLobby(lobbyName); + this.currentLobby = lobbyName; + isHost = true; + } else if (option.equals("join")) { + updateLobbies(sender.requestLobbyList()); + + if (subLobbies.size() == 0) { + System.out.println("No available games at the moment :("); + options(); + } + + System.out.println("Which lobby would you like to join? Here is a list of active games"); + for (int i = 0; i < subLobbies.size(); i++) { + System.out.println(subLobbies.get(i).getLobbyName() + " (" + subLobbies.get(i).getPlayers().size() + "/4)"); + } + String lobbyName = scanner.nextLine(); + this.currentLobby = lobbyName; + isHost = false; + + joinLobby(lobbyName); //Try Catch her måske, kommer and på hvad funktionen skal + } else { + System.out.println("please enter a valid option"); + options(); + } + } catch (Exception e) { + System.out.println(e); + System.out.println("please enter a valid option"); + options(); + } + + if (this.isHost) { + hostOptions(this.currentLobby); + } else { + playerOptions(this.currentLobby); + } + } + + + + public static void main(String[] args) throws IOException { + + Lobby l = new Lobby(); + + + + } +} diff --git a/Tank game - Client/src/LobbySender.java b/Tank game - Client/src/LobbySender.java new file mode 100644 index 00000000..e40ac9a8 --- /dev/null +++ b/Tank game - Client/src/LobbySender.java @@ -0,0 +1,149 @@ +import java.util.ArrayList; +import java.util.List; +import java.util.Scanner; +import java.net.*; +import java.io.*; + +public class LobbySender { + private static DataOutputStream toServer = null; + private static DataInputStream fromServer = null; + + + + int port = 8000; + // ipv4 address for server + String host = "192.168.43.236"; + boolean Continue = true; + Socket socket = null; + String playerID; + Scanner scanner = new Scanner(System.in); + + + LobbySender(String playerID) { + initialize(playerID); + } + + private void initialize(String PlayerID) { + try { + setIP(); + socket = new Socket(host, port); + //System.out.println("Connection to server established "); + toServer = new DataOutputStream(socket.getOutputStream()); + fromServer = new DataInputStream(socket.getInputStream()); + this.playerID = playerID; + } catch (IOException e) { + e.printStackTrace(); + System.out.println("Wrong IP, try again"); + initialize(PlayerID); + } + + } + public void setIP() { + System.out.println("What is the IP address?"); + String IP = scanner.nextLine(); + this.host = IP; + } + + public void setPlayerID(String playerID){ + this.playerID = playerID; + } + + + public void sendPlayerID() throws IOException { + toServer.writeUTF(playerID); + } + + public void recieveGameInfo(){ + + + } + + public void readyGame(String subLobby) throws IOException { + toServer.writeUTF("playerReady"); + toServer.writeUTF(subLobby); + boolean ready = false; + while(!ready) { + toServer.writeUTF("readyGame"); + toServer.writeUTF(subLobby); + ready = fromServer.readBoolean(); + } + } + + public void updateLobby(String playerID, String lobbyName) throws IOException { + toServer.writeUTF("updateLobby"); + toServer.writeUTF(lobbyName); + toServer.writeUTF(playerID); + } + + + public void sendSubLobby(SubLobby lobby) throws IOException { + + toServer.writeUTF("sendSubLobby"); + toServer.writeUTF(lobby.getLobbyName()); + toServer.writeUTF(lobby.getHost()); + + System.out.println("HER SENDES INFO!"); + //int len = lobby.getPlayers().size(); + //toServer.writeInt(len); + //for (int i = 0; i < len; i++){ + //toServer.writeUTF(lobby.getPlayers().get(i)); + //} + } + + + public List updatePlayers(String lobbyName) throws IOException { + List players = new ArrayList<>(); + toServer.writeUTF("updatePlayers"); + toServer.writeUTF(lobbyName); + int len = fromServer.readInt(); + + for(int i = 0; i requestLobbyList() throws IOException { + List subLobbies = new ArrayList(); + toServer.writeUTF("requestLobbyList"); + + int numOfLobbies = fromServer.readInt(); + System.out.println(numOfLobbies); + for(int i = 0; i< numOfLobbies; i++) { + String lobbyName = fromServer.readUTF(); + String host = fromServer.readUTF(); + int len = fromServer.readInt(); + List players = new ArrayList(); + for (int j = 0; j < len; j++) { + players.add(fromServer.readUTF()); + } + System.out.println("Recieved sublobby: "+lobbyName); + SubLobby newLobby = new SubLobby(lobbyName, host); + newLobby.setPlayers(players); + subLobbies.add(newLobby); + } + System.out.println("recieving done!"); + return subLobbies; + } + + + + public static DataInputStream getFromServer() { + return fromServer; + } + + public static DataOutputStream getToServer() { + return toServer; + } + + +} + + + + + + diff --git a/Tank game - Client/src/Map.java b/Tank game - Client/src/Map.java new file mode 100644 index 00000000..1a8332f0 --- /dev/null +++ b/Tank game - Client/src/Map.java @@ -0,0 +1,19 @@ +import javafx.scene.paint.Color; +import javafx.scene.shape.Rectangle; + +public class Map extends Rectangle { + //final static Color color = Color.GRAY; + //final static int width = 1200; + //final static int height = 5; + + + + Map(int x, int y, int width, int height){ + super(); + setHeight(height); + setWidth(width); + setTranslateX(x); + setTranslateY(y); + } +} + diff --git a/Tank game - Client/src/NewMap.java b/Tank game - Client/src/NewMap.java new file mode 100644 index 00000000..04a18fbc --- /dev/null +++ b/Tank game - Client/src/NewMap.java @@ -0,0 +1,5 @@ +public class NewMap { + + + +} diff --git a/Tank game - Client/src/Projectile.java b/Tank game - Client/src/Projectile.java new file mode 100644 index 00000000..bd95fda4 --- /dev/null +++ b/Tank game - Client/src/Projectile.java @@ -0,0 +1,60 @@ +import javafx.scene.paint.Color; +import javafx.scene.shape.Circle; + +public class Projectile extends Circle { + + final static int MAX_SPEED = 1; + static final int RADIUS = 5; + + private Tank player; + + private double xSpeed; + private double ySpeed; + public boolean dead = false; + int angle; + double angleR; + int lifespan; + + Projectile(float x, float y, Tank tank) { + super(x, y, RADIUS); //bruger constructor fra Rectangle som er superclass + setFill(Color.HOTPINK); + this.angle = tank.getAngle(); //henter den vinkel tanken har + this.angleR = Math.toRadians(angle); //laver vinklen til radianer + //this.player = tank; //gemmer hvilken tank der har affyret + setSpeed(); //kalder metoden set speed og gemmer en x og y speed + } + + void setSpeed() { + //sets x and y speed according the the tanks angle in radians + this.xSpeed = MAX_SPEED * Math.cos(angleR); + this.ySpeed = MAX_SPEED * Math.sin(angleR); + } + + void moveBullet(Map map) { + this.setCenterX(getCenterX() + xSpeed); //affyrer skud med dens vinkel fra setSpeed + this.setCenterY(getCenterY() + ySpeed); + + + if (this.getCenterX() > map.getTranslateX() && this.getCenterX() < map.getTranslateX() + map.getWidth() && (this.getCenterY() < map.getTranslateY() || this.getCenterY() < map.getTranslateY() + map.getHeight()+RADIUS) && this.getBoundsInParent().intersects(map.getBoundsInParent())) { + ySpeed = -ySpeed; //inverter hastigheden hvis en top eller bund væg rammes + } else if (this.getBoundsInParent().intersects(map.getBoundsInParent())) { + xSpeed = -xSpeed; //inverter speed hvis sidevæg rammes + } + lifespan++; //incrementer lifespan hver frame + } + + + Tank collision(Tank[] tank){ //method that returns a tank that has been hit + for (int i = 0; i < tank.length; i++) { + if (this.getBoundsInParent().intersects(tank[i].getBoundsInParent())) { + //lifespan = 300; + return tank[i]; + } + } + return null; + } + + public int getLifespan() { + return lifespan; + } +} diff --git a/Tank game - Client/src/SubLobby.java b/Tank game - Client/src/SubLobby.java new file mode 100644 index 00000000..88a2c4ae --- /dev/null +++ b/Tank game - Client/src/SubLobby.java @@ -0,0 +1,46 @@ +import java.util.ArrayList; +import java.util.List; + +public class SubLobby { + private String lobbyName; + private List players = new ArrayList(); + private String host; + + + SubLobby(String lobbyName, String host){ + this.lobbyName = lobbyName; + this.host = host; + addToPlayers(host); + + + } + + + void addToPlayers(String p) { + this.players.add(p); + + } + + public void setPlayers(List players){ + this.players = players; + + } + + public String getLobbyName() { + return lobbyName; + } + + public List getPlayers() { + return players; + } + + public void printPlayers(){ + for (int i = 0; i < players.size(); i++) { + System.out.println(" - "+players.get(i)); + } + } + + public String getHost() { + return host; + } +} diff --git a/Tank game - Client/src/TODO list b/Tank game - Client/src/TODO list new file mode 100644 index 00000000..0e175e6d --- /dev/null +++ b/Tank game - Client/src/TODO list @@ -0,0 +1,25 @@ +Fjern bullets +DONE> efter timer +DONE> efter ramt tank + +Lav colission +> tank --> væg +> tank --> tank +DONE> bullet --> tank + +Map + +Lobby + +Scoreboard + +End game screen + +List af ting vi skal sende til serveren + +Liste vi skal bruge fra serveren +> array med tanks +> tank ID + +PlayerID +> synkronisering mellem classes \ No newline at end of file diff --git a/Tank game - Client/src/Tank game - Client.iml b/Tank game - Client/src/Tank game - Client.iml new file mode 100644 index 00000000..b107a2dd --- /dev/null +++ b/Tank game - Client/src/Tank game - Client.iml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/Tank game - Client/src/Tank.java b/Tank game - Client/src/Tank.java new file mode 100644 index 00000000..69294b30 --- /dev/null +++ b/Tank game - Client/src/Tank.java @@ -0,0 +1,101 @@ +import javafx.scene.paint.Color; +import javafx.scene.shape.Rectangle; +import javafx.scene.transform.Rotate; + +public class Tank extends Rectangle { + boolean dead = false; //is not used for anything YET + private int angle = 0; //variable that stores the tanks angle + private int angleIncrease = 3; + private int moveSpeed = 3; + private int wallCollider = 50; + final static int MAX_PROJECTILES = 10; //max amount of projectiles a player can have at the same time + private Projectile[] projectiles = new Projectile[MAX_PROJECTILES]; //array with the tanks projectiles + final String playerID; //either bullet or player-- IS NOT UTILISED YET + + Tank(int x, int y, int w, int h, String playerID, Color color) { //constructor + super(w, h, color); + this.playerID = playerID; + setTranslateX(x); + setTranslateY(y); + } + + public Projectile[] getProjectiles() { + return projectiles; //returns the tanks array of projectiles + } + + + void setDead(){ + dead = true; + } + boolean getDead(){ + return dead; + } + + Projectile shoot() { //shoot method, returns a projectile array or null + if(!dead) { + for (int i = 0; i < projectiles.length; i++) { + if (projectiles[i] == null) { //let's the player shoot if there is an empty space in the array aka. there are less than 10 bullets on the map + int k = 60; //offset value + + //x and y for the center of the tank + float centerX = (float) this.getTranslateX() + (float) this.getWidth() / 2; //center of tank + float centerY = (float) this.getTranslateY() + (float) this.getHeight() / 2; + + //cos and sin for the tanks angle + float cos = (float) Math.cos(Math.toRadians(getAngle() * -1)); + float sin = (float) Math.sin(Math.toRadians(getAngle() * -1)); + + //cos and sin multiplied with a constant, calculating the x and y offset + float widthOffset = cos * k; + float heightOffset = sin * k; + + //start coordinates for x and y + float x = centerX + widthOffset; + float y = centerY - heightOffset; + + Projectile p = new Projectile(x, y, this); //creates a new projectile + projectiles[i] = p; //puts the bullets in the bullet array + return projectiles[i]; //returns the array, now with bullets in it + } + } + } + return null; + + } + + + void rotateLeft() { //function for rotating a sprite left, pivoting around its middle + getTransforms().add(new Rotate(-angleIncrease, getX() + getWidth() / 2, getY() + getHeight() / 2)); + angle += -angleIncrease; + } + + void rotateRight() { //function for rotating a sprite right, pivoting around its middle + getTransforms().add(new Rotate(+angleIncrease, getX() + getWidth() / 2, getY() + getHeight() / 2)); + angle += angleIncrease; + } + + void moveForward() { + double angleR = Math.toRadians(angle); + setTranslateX(getTranslateX() + moveSpeed * Math.cos(angleR)); + setTranslateY(getTranslateY() + moveSpeed * Math.sin(angleR)); + } + + void moveBackward() { + double angleR = Math.toRadians(angle); + setTranslateX(getTranslateX() - moveSpeed * Math.cos(angleR)); + setTranslateY(getTranslateY() - moveSpeed * Math.sin(angleR)); + } + + public boolean isColliding(Map[] maps){ //method that returns true if colliding with a wall + for (int i = 0; i < maps.length; i++) { + if (this.getBoundsInParent().intersects(maps[i].getBoundsInParent())) { + return true; + } + } + return false; + } + + public int getAngle() { + return angle; + } +} diff --git a/Tank game - Client/src/test5.java b/Tank game - Client/src/test5.java new file mode 100644 index 00000000..42e523de --- /dev/null +++ b/Tank game - Client/src/test5.java @@ -0,0 +1,109 @@ +import javafx.animation.AnimationTimer; +import javafx.application.Application; +import javafx.scene.Parent; +import javafx.scene.Scene; +import javafx.scene.layout.Pane; +import javafx.scene.paint.Color; +import javafx.stage.Stage; + +import java.util.List; +import java.util.stream.Collectors; +/* +public class test5 extends Application { + private Pane root = new Pane(); + int width = 1200; + int height = 700; + + private Tank player = new Tank(300, 300, 70, 40, "player", Color.BLUE); + + + private Parent createContent() { + root.setPrefSize(width, height); + root.getChildren().add(player); + + + AnimationTimer timer = new AnimationTimer() { + @Override + public void handle(long now) { + update(); + } + }; + timer.start(); + //nextLevel(); //initiater enemies - skal slette + return root; + } + + /* private void nextLevel() { //laver de røde enemies - skal slettes senere + for (int i = 0; i < 10; i++) { + Sprite s = new Sprite(90 + i * 100, 150, 30, 30, "enemy", Color.RED); + root.getChildren().add(s); + } + } + + */ + + /* private List projectiles() { //funktion der returner en liste + System.out.println(root.getChildren().stream().map(n -> (Projectile) n).collect(Collectors.toList())); + return root.getChildren().stream().map(n -> (Projectile) n).collect(Collectors.toList()); + } + + */ + + /* private void update() { + projectiles().forEach(p -> { //handles what happens to the sprites/bullets + final int angle = player.getAngle(); + p.moveBullet(); + if (p.getBoundsInParent().intersects(player.getBoundsInParent())) { + player.dead = true; + p.dead = true; + } + }); + + + + root.getChildren().removeIf(n -> { + Projectile p = (Projectile) n; + return p.dead; + }); + } + + private void shoot(Tank who) { //shoot function, creates sprites from shooting player + int bulletW = 5; //bullet width + int bulletH = 5; //bullet height + Projectile p = new Projectile((int) who.getTranslateX() + (int) who.getWidth() / 2, (int) who.getTranslateY() + (int) who.getHeight() / 2, who); + //Sprite s = new Sprite((int) who.getTranslateX() + (int) who.getWidth() / 2, (int) who.getTranslateY() + (int) who.getHeight() / 2, bulletW, bulletH, who.type + "bullet", Color.BLACK); + //root.getChildren().add(s); + root.getChildren().add(p); + } + + public void start(Stage stage) throws Exception { + Scene scene = new Scene(createContent()); + + scene.setOnKeyPressed(e -> { //movement switch case + switch (e.getCode()) { + case LEFT: + player.rotateLeft(); + break; + case RIGHT: + player.rotateRight(); + break; + case UP: + player.moveForward(); + break; + case DOWN: + player.moveBackward(); + break; + case SPACE: + shoot(player); + } + }); + stage.setScene(scene); + stage.show(); + } + + public static void main(String[] args) { + launch(args); + } +} + +*/ \ No newline at end of file diff --git a/Tank game - Client/src/update b/Tank game - Client/src/update new file mode 100644 index 00000000..578abd17 --- /dev/null +++ b/Tank game - Client/src/update @@ -0,0 +1,29 @@ + private void update() { + sprites().forEach(s -> { //handles what happens to the sprites/bullets + switch (s.type) { + /*case "enemybullet": + if (s.getBoundsInParent().intersects(player.getBoundsInParent())) { + player.dead = true; + s.dead = true; + } + break; + */ + + case "playerbullet": + final int angle = player.getAngle(); + s.moveBullet(angle); + sprites().stream().filter(e -> e.type.equals("enemy")).forEach(enemy -> { + if (s.getBoundsInParent().intersects(enemy.getBoundsInParent())) { + enemy.dead = true; + s.dead = true; + } + }); + break; + } + }); + + root.getChildren().removeIf(n -> { + Sprite s = (Sprite) n; + return s.dead; + }); + } \ No newline at end of file