mirror of
https://github.com/jokerx3/HeatUp
synced 2026-07-27 10:19:46 +02:00
MapEngine: "Magic Number" hinzugefügt
MapObjectHandler: Bugfix.
This commit is contained in:
@@ -14,6 +14,10 @@ import de.heatup.logging.Logger;
|
|||||||
import de.heatup.objects.*;
|
import de.heatup.objects.*;
|
||||||
|
|
||||||
public class MapEngine {
|
public class MapEngine {
|
||||||
|
/*
|
||||||
|
* MAGIC NUMBER SINGLE TILE WIDTH
|
||||||
|
*/
|
||||||
|
private static final int singleTileWidth = 25;
|
||||||
final int mapHeight = 24;
|
final int mapHeight = 24;
|
||||||
final int mapWidth = 32;
|
final int mapWidth = 32;
|
||||||
HashMap<Character, ArrayList<Point>> allMapTiles = new HashMap<Character, ArrayList<Point>>();
|
HashMap<Character, ArrayList<Point>> allMapTiles = new HashMap<Character, ArrayList<Point>>();
|
||||||
@@ -78,11 +82,11 @@ public class MapEngine {
|
|||||||
/*
|
/*
|
||||||
* setze x und y auf die koordinaten für das objekt im NÄCHSTEN durchlauf
|
* setze x und y auf die koordinaten für das objekt im NÄCHSTEN durchlauf
|
||||||
*/
|
*/
|
||||||
if (x+25 >= 800) {
|
if (x+singleTileWidth >= 800) {
|
||||||
x = 0;
|
x = 0;
|
||||||
y += 25;
|
y += singleTileWidth;
|
||||||
} else {
|
} else {
|
||||||
x += 25;
|
x += singleTileWidth;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
lineCount++;
|
lineCount++;
|
||||||
|
|||||||
@@ -36,17 +36,28 @@ public class MapObjectHandler {
|
|||||||
MapObjectHandler.allMapObjects.add(newStaticObject);
|
MapObjectHandler.allMapObjects.add(newStaticObject);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
|
* die ganze methode ist unglaublich schlechter und hässlicher programmierstil, aber das weiß ich und ändere ich noch.
|
||||||
|
*
|
||||||
|
* mfg daniel. :)
|
||||||
|
*/
|
||||||
protected static void addAllWallsAndWaysTiles(MapEngine me) {
|
protected static void addAllWallsAndWaysTiles(MapEngine me) {
|
||||||
for (int i = 0; i<me.getAvailableHardwareTileTypes().size(); i++) {
|
ArrayList<Point> allCoordinatesOfWayTileType = me.getAllCoordinatesOfTileType('#');
|
||||||
char currentType = me.getAvailableHardwareTileTypes().get(i);
|
ArrayList<Point> allCoordinatesOfWallTileType = me.getAllCoordinatesOfTileType('-');
|
||||||
if (currentType == '#' || currentType == '-') {
|
|
||||||
ArrayList<Point> allPointsOfCurrentType = me.getAllCoordinatesOfTileType(currentType);
|
for (int i = 0; i < allCoordinatesOfWayTileType.size(); i++) {
|
||||||
for (int j = 0; j<allPointsOfCurrentType.size(); j++) {
|
Point currentPoint = allCoordinatesOfWayTileType.get(i);
|
||||||
Point currentPoint = allPointsOfCurrentType.get(j);
|
StaticObject newStaticObject = new StaticObject('#', currentPoint);
|
||||||
StaticObject newStaticObject = new StaticObject(currentType, currentPoint);
|
MapObjectHandler.allMapObjects.add(newStaticObject);
|
||||||
MapObjectHandler.allMapObjects.add(newStaticObject);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
for (int i = 0; i < allCoordinatesOfWallTileType.size(); i++) {
|
||||||
|
Point currentPoint = allCoordinatesOfWallTileType.get(i);
|
||||||
|
StaticObject newStaticObject = new StaticObject('-', currentPoint);
|
||||||
|
MapObjectHandler.allMapObjects.add(newStaticObject);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user