From 9114d0d2c3f45c72dc61733ab85c340176477dff Mon Sep 17 00:00:00 2001 From: toksikk Date: Wed, 5 Nov 2014 10:42:15 +0100 Subject: [PATCH] Bugfix MapGrid. Methode zur Ausgabe des MapGrids inklusive Triggerzonen --- HeatUp/src/de/heatup/mapengine/MapEngine.java | 18 ++++++++++++++++++ HeatUp/src/de/heatup/mapengine/MapGrid.java | 14 +++++++------- .../{GridCell.java => MapGridCell.java} | 2 +- HeatUp/src/de/heatup/resources/maps/map1.txt | 8 ++++---- 4 files changed, 30 insertions(+), 12 deletions(-) rename HeatUp/src/de/heatup/mapengine/{GridCell.java => MapGridCell.java} (96%) diff --git a/HeatUp/src/de/heatup/mapengine/MapEngine.java b/HeatUp/src/de/heatup/mapengine/MapEngine.java index 2ab201e..33c8523 100644 --- a/HeatUp/src/de/heatup/mapengine/MapEngine.java +++ b/HeatUp/src/de/heatup/mapengine/MapEngine.java @@ -203,4 +203,22 @@ public class MapEngine { } return false; } + public void printMapGridWithTriggers() { + for (int i = 0; i < 24; i++) { + for (int j = 0; j < 32; j++) { + if (!MapGrid.getGridCell(j, i).isPath() && !MapGrid.getGridCell(j, i).isTrigger()) { + System.out.print("-"); + } else { + if (MapGrid.getGridCell(j, i).isTrigger()) { + System.out.print(MapGrid.getGridCell(j, i).getCorrespondingHardwareToTrigger()+""); + } + if (MapGrid.getGridCell(j, i).isPath() && !MapGrid.getGridCell(j, i).isTrigger()) { + System.out.print("#"); + } + } + + } + System.out.println(); + } + } } diff --git a/HeatUp/src/de/heatup/mapengine/MapGrid.java b/HeatUp/src/de/heatup/mapengine/MapGrid.java index fa8b633..a9c3520 100644 --- a/HeatUp/src/de/heatup/mapengine/MapGrid.java +++ b/HeatUp/src/de/heatup/mapengine/MapGrid.java @@ -3,18 +3,18 @@ package de.heatup.mapengine; import de.heatup.cfg.Config; public class MapGrid { - private static GridCell[][] allGridCells = new GridCell[Config.mapMaxTilesWidth][Config.mapMaxTilesHeight]; - private static GridCell dummyCell = new GridCell(); // wird zurückgegeben, falls der MapGrid index ausserhalb unserer allGridCells dimension zeigt. + private static MapGridCell[][] allGridCells = new MapGridCell[Config.mapMaxTilesWidth][Config.mapMaxTilesHeight]; + private static MapGridCell dummyCell = new MapGridCell(); // wird zurückgegeben, falls der MapGrid index ausserhalb unserer allGridCells dimension zeigt. protected static void addGrid(int x, int y, boolean isPath) { if (!(x < 0 || x > Config.mapMaxTilesWidth || y < 0 || y > Config.mapMaxTilesHeight)) { - GridCell newCell = new GridCell(); + MapGridCell newCell = new MapGridCell(); newCell.setPath(isPath); allGridCells[x][y] = newCell; } } protected static void addGrid(int x, int y, boolean isPath, boolean isTrigger, char correspondingHardwareToTrigger) { if (!(x < 0 || x > Config.mapMaxTilesWidth || y < 0 || y > Config.mapMaxTilesHeight)) { - GridCell newCell = new GridCell(); + MapGridCell newCell = new MapGridCell(); newCell.setPath(isPath); newCell.setTrigger(isTrigger); newCell.setCorrespondingHardwareToTrigger(correspondingHardwareToTrigger); @@ -23,14 +23,14 @@ public class MapGrid { } protected static void addGrid(int x, int y, boolean isTrigger, char correspondingHardwareToTrigger) { if (!(x < 0 || x > Config.mapMaxTilesWidth || y < 0 || y > Config.mapMaxTilesHeight)) { - GridCell newCell = new GridCell(); + MapGridCell newCell = new MapGridCell(); newCell.setTrigger(isTrigger); newCell.setCorrespondingHardwareToTrigger(correspondingHardwareToTrigger); allGridCells[x][y] = newCell; } } - public static GridCell getGridCell(int x, int y) { - if (!(x < 0 || x > Config.mapMaxTilesWidth || y < 0 || y > Config.mapMaxTilesHeight)) { + public static MapGridCell getGridCell(int x, int y) { + if (!(x < 0 || x > Config.mapMaxTilesWidth-1 || y < 0 || y > Config.mapMaxTilesHeight-1)) { return allGridCells[x][y]; } return dummyCell; diff --git a/HeatUp/src/de/heatup/mapengine/GridCell.java b/HeatUp/src/de/heatup/mapengine/MapGridCell.java similarity index 96% rename from HeatUp/src/de/heatup/mapengine/GridCell.java rename to HeatUp/src/de/heatup/mapengine/MapGridCell.java index 5192275..0713ac5 100644 --- a/HeatUp/src/de/heatup/mapengine/GridCell.java +++ b/HeatUp/src/de/heatup/mapengine/MapGridCell.java @@ -1,6 +1,6 @@ package de.heatup.mapengine; -public class GridCell { +public class MapGridCell { private boolean isPath = false; private boolean isTrigger = false; private char correspondingHardwareToTrigger; diff --git a/HeatUp/src/de/heatup/resources/maps/map1.txt b/HeatUp/src/de/heatup/resources/maps/map1.txt index 3c648a4..136c4bf 100644 --- a/HeatUp/src/de/heatup/resources/maps/map1.txt +++ b/HeatUp/src/de/heatup/resources/maps/map1.txt @@ -1,4 +1,4 @@ -################################ +###1111######################### #--1111----#----------#222222--# #--1111----#----------#222222--# #######################222222### @@ -19,6 +19,6 @@ -666#---#-###---####-####--#-##- -666#---#---#-###777-#--##----#- -666#####---###-#777-#---####### -----#-------#---##########88888# ----##########------#------88888# -------------#################### \ No newline at end of file +----#-------#---##########888888 +---##########------#------888888 +------------####################