Karte kann nun skalieren.

Config.setGamePanelWidth(int width);
This commit is contained in:
toksikk
2014-11-03 15:03:59 +01:00
parent 6a9c89d02e
commit 15872210fb
2 changed files with 12 additions and 3 deletions
+10 -2
View File
@@ -5,10 +5,18 @@ package de.heatup.cfg;
*/ */
public class Config { public class Config {
/* /*
* Map related magic numbers * de.heatup.mapengine.*
*/ */
public static final int singleTilePixels = 25;
public static final int triggerAreaAddition = 20; public static final int triggerAreaAddition = 20;
public static final int mapMaxTilesWidth = 32; public static final int mapMaxTilesWidth = 32;
public static final int mapMaxTilesHeight = 24; public static final int mapMaxTilesHeight = 24;
public static int gamePanelWidth = 800;
public static int singleTilePixels = gamePanelWidth/mapMaxTilesWidth;
public static void setGamePanelWidth(int width) {
gamePanelWidth = width;
updateSingleTilePixels();
}
private static void updateSingleTilePixels() {
singleTilePixels = gamePanelWidth/mapMaxTilesHeight;
}
} }
@@ -20,6 +20,7 @@ public class MapEngine {
private static final int singleTileWidth = Config.singleTilePixels; private static final int singleTileWidth = Config.singleTilePixels;
private final int mapHeight = Config.mapMaxTilesHeight; private final int mapHeight = Config.mapMaxTilesHeight;
private final int mapWidth = Config.mapMaxTilesWidth; private final int mapWidth = Config.mapMaxTilesWidth;
private final int gamePanelWidth = Config.gamePanelWidth;
HashMap<Character, ArrayList<Point>> allMapTiles = new HashMap<Character, ArrayList<Point>>(); HashMap<Character, ArrayList<Point>> allMapTiles = new HashMap<Character, ArrayList<Point>>();
ArrayList<Character> availableHardwareTileTypes = new ArrayList<Character>(); ArrayList<Character> availableHardwareTileTypes = new ArrayList<Character>();
@@ -70,7 +71,7 @@ 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+singleTileWidth >= 800) { if (x+singleTileWidth >= gamePanelWidth) {
x = 0; x = 0;
y += singleTileWidth; y += singleTileWidth;
} else { } else {