mirror of
https://github.com/jokerx3/HeatUp
synced 2026-07-27 08:49:44 +02:00
Bugfix MapGrid.
Methode zur Ausgabe des MapGrids inklusive Triggerzonen
This commit is contained in:
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
+1
-1
@@ -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;
|
||||
@@ -1,4 +1,4 @@
|
||||
################################
|
||||
###1111#########################
|
||||
#--1111----#----------#222222--#
|
||||
#--1111----#----------#222222--#
|
||||
#######################222222###
|
||||
@@ -19,6 +19,6 @@
|
||||
-666#---#-###---####-####--#-##-
|
||||
-666#---#---#-###777-#--##----#-
|
||||
-666#####---###-#777-#---#######
|
||||
----#-------#---##########88888#
|
||||
---##########------#------88888#
|
||||
------------####################
|
||||
----#-------#---##########888888
|
||||
---##########------#------888888
|
||||
------------####################
|
||||
|
||||
Reference in New Issue
Block a user