From f5bed7c8b97721674c91eda0a9079692486289c7 Mon Sep 17 00:00:00 2001
From: yschl <ys037@hdm-stuttgart.de>
Date: Wed, 17 Jan 2024 11:49:48 +0100
Subject: [PATCH] GameSceneController.java: Add: Changed testmap, Added new
 Tiles and upped the diffTileCount Player.java: Fix: Small addition of test so
 that explosions shouldnt go out of the map (Some still do), Add: Check of new
 Non_Destructible Tile in checkTileNOon_destructible Method TileManager.java:
 Add: 2 new Tiles + png's

---
 .../Controller/GameSceneController.java       | 24 ++++++++++++++++---
 .../battlearena/Model/Entity/Player.java      |  8 +++----
 .../battlearena/Model/Map/TileManager.java    |  4 ++++
 3 files changed, 29 insertions(+), 7 deletions(-)

diff --git a/src/main/java/de/hdm_stuttgart/battlearena/Controller/GameSceneController.java b/src/main/java/de/hdm_stuttgart/battlearena/Controller/GameSceneController.java
index 008e1ecc..0c6e24ee 100644
--- a/src/main/java/de/hdm_stuttgart/battlearena/Controller/GameSceneController.java
+++ b/src/main/java/de/hdm_stuttgart/battlearena/Controller/GameSceneController.java
@@ -47,7 +47,7 @@ public class GameSceneController implements Initializable {
     TileManager tileManager;
 
     //map data
-    String mapString =  "4 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 " +
+    /*String mapString =  "4 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 " +
                         "4 1 2 1 1 1 1 2 2 2 1 1 1 1 1 1 1 3 " +
                         "4 2 1 1 1 1 1 2 2 2 1 1 1 1 2 1 1 3 " +
                         "4 1 1 1 2 2 4 3 3 1 4 3 3 3 3 2 2 3 " +
@@ -64,10 +64,28 @@ public class GameSceneController implements Initializable {
                         "4 1 1 2 1 1 1 2 2 2 1 1 1 1 1 1 1 3 " +
                         "4 1 1 1 2 2 4 3 3 1 3 3 3 3 3 2 2 3 " +
                         "4 1 1 1 2 2 4 3 3 1 3 3 3 3 3 2 2 3 " +
-                        "4 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 ";
+                        "4 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 ";*/
+        String mapString =  "4 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 " +
+                            "4 1 9 1 9 1 9 1 9 1 9 1 9 1 9 1 9 3 " +
+                            "4 9 10 9 10 9 10 9 10 9 10 9 10 9 10 9 10 3 " +
+                            "4 1 9 1 9 1 9 1 9 1 9 1 9 1 9 1 9 3 " +
+                            "4 9 10 9 10 9 10 9 10 9 10 9 10 9 10 9 10 3 " +
+                            "4 1 9 1 9 1 9 1 9 1 9 1 9 1 9 1 9 3 " +
+                            "4 9 10 9 10 9 10 9 10 9 10 9 10 9 10 9 10 3 " +
+                            "4 1 9 1 9 1 9 1 9 1 9 1 9 1 9 1 9 3 " +
+                            "4 9 10 9 10 9 10 9 10 9 10 9 10 9 10 9 10 3 " +
+                            "4 1 9 1 9 1 9 1 9 1 9 1 9 1 9 1 9 3 " +
+                            "4 9 10 9 10 9 10 9 10 9 10 9 10 9 10 9 10 3 " +
+                            "4 1 9 1 9 1 9 1 9 1 9 1 9 1 9 1 9 3 " +
+                            "4 9 10 9 10 9 10 9 10 9 10 9 10 9 10 9 10 3 " +
+                            "4 1 9 1 9 1 9 1 9 1 9 1 9 1 9 1 9 3 " +
+                            "4 9 10 9 10 9 10 9 10 9 10 9 10 9 10 9 10 3 " +
+                            "4 1 9 1 9 1 9 1 9 1 9 1 9 1 9 1 9 3 " +
+                            "4 9 10 9 10 9 10 9 10 9 10 9 10 9 10 9 10 3 " +
+                            "4 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 ";
     int horizontalTileCount = 18;
     int verticalTileCount = 18;
-    int diffTileCount = 10;
+    int diffTileCount = 12;
     int scaledTileSize = 48;
 
 
diff --git a/src/main/java/de/hdm_stuttgart/battlearena/Model/Entity/Player.java b/src/main/java/de/hdm_stuttgart/battlearena/Model/Entity/Player.java
index 89ed0203..5fdfadc9 100644
--- a/src/main/java/de/hdm_stuttgart/battlearena/Model/Entity/Player.java
+++ b/src/main/java/de/hdm_stuttgart/battlearena/Model/Entity/Player.java
@@ -312,17 +312,17 @@ class Player implements IEntity {
                        }*/
                     }
                     isDestructible = checkTileNon_Destructible(yTile -1 -i, xTile);
-                    if(isDestructible && (yTile < 18 && xTile <18)){
+                    if(isDestructible && (yTile < 18 && xTile <18 && yTile > 0 && xTile > 0)){
                         TileManager.tileMap[yTile -1 -i][xTile] = 8;
                         entity.gotHit(2);
                     }
                     isDestructible = checkTileNon_Destructible(yTile , xTile +1 +i);
-                    if(isDestructible && (yTile < 18 && xTile <18)){
+                    if(isDestructible && (yTile < 18 && xTile <18 && yTile > 0 && xTile > 0)){
                         TileManager.tileMap[yTile][xTile +1 +i] = 8;
                         entity.gotHit(2);
                     }
                     isDestructible = checkTileNon_Destructible(yTile, xTile -1 -i);
-                    if(isDestructible && (yTile < 18 && xTile <18)){
+                    if(isDestructible && (yTile < 18 && xTile <18 && yTile > 0 && xTile > 0)){
                         TileManager.tileMap[yTile][xTile -1 -i] = 8;
                         entity.gotHit(2);
                     }
@@ -346,7 +346,7 @@ class Player implements IEntity {
     }
     public boolean checkTileNon_Destructible(int y, int x){     //Change it with a DestructionHandler like CollisionHandler
         //tileSet[xTile].getDestruction();
-        if(TileManager.tileMap[y][x] != 4 && TileManager.tileMap[y][x] != 3){
+        if(TileManager.tileMap[y][x] != 10 && TileManager.tileMap[y][x] != 3 && TileManager.tileMap[y][x] != 4){
             return true;
         }
         return false;
diff --git a/src/main/java/de/hdm_stuttgart/battlearena/Model/Map/TileManager.java b/src/main/java/de/hdm_stuttgart/battlearena/Model/Map/TileManager.java
index 29c09eef..89303569 100644
--- a/src/main/java/de/hdm_stuttgart/battlearena/Model/Map/TileManager.java
+++ b/src/main/java/de/hdm_stuttgart/battlearena/Model/Map/TileManager.java
@@ -52,6 +52,10 @@ public class TileManager {
                     new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/bigbomba.png"))));
             tileSet[8] = TileFactory.createTile(TileType.WALKABLE,TileType.NON_DESTRUCTIBLE,
                     new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/middlexplosion.png"))));
+            tileSet[9] = TileFactory.createTile(TileType.NON_WALKABLE,TileType.DESTRUCTIBLE,
+                    new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/box.png"))));
+            tileSet[10] = TileFactory.createTile(TileType.NON_WALKABLE,TileType.NON_DESTRUCTIBLE,
+                    new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/solidstone.png"))));
         } catch (Exception e) {
             log.error(e);
         }
-- 
GitLab