diff --git a/HeatUp/src/de/heatup/cfg/Config.java b/HeatUp/src/de/heatup/cfg/Config.java new file mode 100644 index 0000000..79fd2ab --- /dev/null +++ b/HeatUp/src/de/heatup/cfg/Config.java @@ -0,0 +1,28 @@ +package de.heatup.cfg; + +import de.heatup.logging.Logger; + +/* + * Bitte hier eure Magicnumbers eintragen + */ +public class Config { + /* + * de.heatup.mapengine.* + */ + public static final int triggerAreaAddition = 20; + public static final int mapMaxTilesWidth = 32; + public static final int mapMaxTilesHeight = 24; + public static int gamePanelWidth = 800; + public static int singleTilePixels = gamePanelWidth/mapMaxTilesWidth; + public static void setGamePanelWidth(int width) { + // Wir wollen hier keine Reste! + while (width % mapMaxTilesHeight != 0) { + width--; + } + gamePanelWidth = width; + updateSingleTilePixels(); + } + private static void updateSingleTilePixels() { + singleTilePixels = gamePanelWidth/mapMaxTilesHeight; + } +} diff --git a/HeatUp/src/de/heatup/mapengine/MapEngine.java b/HeatUp/src/de/heatup/mapengine/MapEngine.java index ba58d13..5808d1d 100644 --- a/HeatUp/src/de/heatup/mapengine/MapEngine.java +++ b/HeatUp/src/de/heatup/mapengine/MapEngine.java @@ -10,24 +10,22 @@ import java.util.HashMap; import java.util.Scanner; import javax.swing.JFileChooser; + +import de.heatup.cfg.Config; import de.heatup.logging.Logger; import de.heatup.objects.*; public class MapEngine { - /* - * MAGIC NUMBER SINGLE TILE WIDTH - */ - private static final int singleTileWidth = 25; - final int mapHeight = 24; - final int mapWidth = 32; + + private static final int singleTileWidth = Config.singleTilePixels; + private final int mapHeight = Config.mapMaxTilesHeight; + private final int mapWidth = Config.mapMaxTilesWidth; + private final int gamePanelWidth = Config.gamePanelWidth; + HashMap> allMapTiles = new HashMap>(); ArrayList availableHardwareTileTypes = new ArrayList(); - char[][] tiles; - /* - * öffnet die map mit der gegebenen nummer aus den resourcen. - */ + public MapEngine(int mapNumber) { - tiles = new char[mapHeight][mapWidth]; Scanner input = null; try { input = new Scanner(new File("src/de/heatup/resources/maps/map"+mapNumber+".txt")); @@ -38,11 +36,7 @@ public class MapEngine { } this.createTiles(input); } - /* - * öffnet einen file chooser um eine benutzer erstellte map zu öffnen - */ public MapEngine() { - tiles = new char[mapHeight][mapWidth]; Scanner input = null; try { JFileChooser chooser = new JFileChooser(); @@ -62,11 +56,6 @@ public class MapEngine { while (input.hasNextLine() && lineCount <= mapHeight) { String currentLine = input.nextLine(); for (int i = 0; i newTileType = new ArrayList(); newTileType.add(new Point(x,y)); @@ -82,7 +71,7 @@ public class MapEngine { /* * 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; y += singleTileWidth; } else { @@ -139,4 +128,16 @@ public class MapEngine { public ArrayList getAllMapObjects() { return MapObjectHandler.getAllMapObjects(this); } + public ArrayList getAllHardwareObjects() { + return MapObjectHandler.getAllHardwareObjects(); + } + public ArrayList getAllWallObjects() { + return MapObjectHandler.getAllWallObjects(); + } + public ArrayList getAllWayObjects() { + return MapObjectHandler.getAllWayObjects(); + } + public ArrayList getAllHardwareTriggerObjects() { + return MapObjectHandler.getAllHardwareTriggerObjects(); + } } diff --git a/HeatUp/src/de/heatup/mapengine/MapObjectHandler.java b/HeatUp/src/de/heatup/mapengine/MapObjectHandler.java index 69ce574..8e858e1 100644 --- a/HeatUp/src/de/heatup/mapengine/MapObjectHandler.java +++ b/HeatUp/src/de/heatup/mapengine/MapObjectHandler.java @@ -3,17 +3,21 @@ package de.heatup.mapengine; import java.awt.Point; import java.util.ArrayList; +import de.heatup.cfg.Config; import de.heatup.logging.Logger; import de.heatup.objects.StaticObject; public class MapObjectHandler { - /* - * MAGIC NUMBER SINGLE TILE WIDTH - */ - private static final int singleTileWidth = 25; + private static final int singleTileWidth = Config.singleTilePixels; + private static final int triggerAreaAddition = Config.triggerAreaAddition; private static ArrayList allMapObjects = new ArrayList(); + private static ArrayList allWallObjects = new ArrayList(); + private static ArrayList allWayObjects = new ArrayList(); + private static ArrayList allHardwareObjects = new ArrayList(); + private static ArrayList allHardwareTriggerObjects = new ArrayList(); + protected static ArrayList getAllMapObjects(MapEngine me) { createAllMapObjectsArrayList(me); return allMapObjects; @@ -32,15 +36,19 @@ public class MapObjectHandler { int currentTilesTotalWidth = lastPoint.x-firstPoint.x+singleTileWidth; int currentTilesTotalHeight = lastPoint.y-firstPoint.y+singleTileWidth; + int currentTriggerTilesTotalWidth = lastPoint.x-firstPoint.x+singleTileWidth+triggerAreaAddition; + int currentTriggerTilesTotalHeight = lastPoint.y-firstPoint.y+singleTileWidth+triggerAreaAddition; + Point currentTriggerTilesFirstPoint = new Point(firstPoint.x-(triggerAreaAddition/2),firstPoint.y-(triggerAreaAddition/2)); + StaticObject newStaticObject = new StaticObject(currentType, firstPoint, currentTilesTotalWidth, currentTilesTotalHeight); + // Trigger Object + // StaticObject newTriggerObject = new StaticObject(currentType, firstPoint, currentTilesTotalWidth, currentTilesTotalHeight, true); MapObjectHandler.allMapObjects.add(newStaticObject); + // MapObjectHandler.allMapObjects.add(newTriggerObject); + MapObjectHandler.allHardwareObjects.add(newStaticObject); + // MapObjectHandler.allHardwareTriggerObjects.add(newTriggerObject); } } - /* - * 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) { ArrayList allCoordinatesOfWayTileType = me.getAllCoordinatesOfTileType('#'); ArrayList allCoordinatesOfWallTileType = me.getAllCoordinatesOfTileType('-'); @@ -49,15 +57,25 @@ public class MapObjectHandler { Point currentPoint = allCoordinatesOfWayTileType.get(i); StaticObject newStaticObject = new StaticObject('#', currentPoint); MapObjectHandler.allMapObjects.add(newStaticObject); + MapObjectHandler.allWayObjects.add(newStaticObject); } for (int i = 0; i < allCoordinatesOfWallTileType.size(); i++) { Point currentPoint = allCoordinatesOfWallTileType.get(i); StaticObject newStaticObject = new StaticObject('-', currentPoint); MapObjectHandler.allMapObjects.add(newStaticObject); + MapObjectHandler.allWallObjects.add(newStaticObject); } - - - - + } + protected static ArrayList getAllHardwareObjects() { + return allHardwareObjects; + } + protected static ArrayList getAllWallObjects() { + return allWallObjects; + } + protected static ArrayList getAllWayObjects() { + return allWayObjects; + } + protected static ArrayList getAllHardwareTriggerObjects() { + return allHardwareTriggerObjects; } } diff --git a/HeatUp/src/de/heatup/resources/images/little_green_guy.png b/HeatUp/src/de/heatup/resources/images/little_green_guy.png index 0a579e2..83c301b 100644 Binary files a/HeatUp/src/de/heatup/resources/images/little_green_guy.png and b/HeatUp/src/de/heatup/resources/images/little_green_guy.png differ diff --git a/HeatUp/src/de/heatup/resources/images/little_green_guy_left.png b/HeatUp/src/de/heatup/resources/images/little_green_guy_left.png index 797885f..20e72c9 100644 Binary files a/HeatUp/src/de/heatup/resources/images/little_green_guy_left.png and b/HeatUp/src/de/heatup/resources/images/little_green_guy_left.png differ diff --git a/HeatUp/src/de/heatup/resources/images/little_green_guy_right.png b/HeatUp/src/de/heatup/resources/images/little_green_guy_right.png index 07c8d4d..a771714 100644 Binary files a/HeatUp/src/de/heatup/resources/images/little_green_guy_right.png and b/HeatUp/src/de/heatup/resources/images/little_green_guy_right.png differ diff --git a/HeatUp/src/de/heatup/resources/images/little_green_guy_up.png b/HeatUp/src/de/heatup/resources/images/little_green_guy_up.png index a268b48..1c44ae7 100644 Binary files a/HeatUp/src/de/heatup/resources/images/little_green_guy_up.png and b/HeatUp/src/de/heatup/resources/images/little_green_guy_up.png differ diff --git a/HeatUp/src/de/heatup/resources/images/old_player/little_green_guy.png b/HeatUp/src/de/heatup/resources/images/old_player/little_green_guy.png new file mode 100644 index 0000000..0a579e2 Binary files /dev/null and b/HeatUp/src/de/heatup/resources/images/old_player/little_green_guy.png differ diff --git a/HeatUp/src/de/heatup/resources/images/old_player/little_green_guy_left.png b/HeatUp/src/de/heatup/resources/images/old_player/little_green_guy_left.png new file mode 100644 index 0000000..797885f Binary files /dev/null and b/HeatUp/src/de/heatup/resources/images/old_player/little_green_guy_left.png differ diff --git a/HeatUp/src/de/heatup/resources/images/old_player/little_green_guy_right.png b/HeatUp/src/de/heatup/resources/images/old_player/little_green_guy_right.png new file mode 100644 index 0000000..07c8d4d Binary files /dev/null and b/HeatUp/src/de/heatup/resources/images/old_player/little_green_guy_right.png differ diff --git a/HeatUp/src/de/heatup/resources/images/old_player/little_green_guy_up.png b/HeatUp/src/de/heatup/resources/images/old_player/little_green_guy_up.png new file mode 100644 index 0000000..a268b48 Binary files /dev/null and b/HeatUp/src/de/heatup/resources/images/old_player/little_green_guy_up.png differ diff --git a/HeatUp/src/de/heatup/resources/images/ways/way_5.jpg b/HeatUp/src/de/heatup/resources/images/ways/way_5.jpg new file mode 100644 index 0000000..ee7342f Binary files /dev/null and b/HeatUp/src/de/heatup/resources/images/ways/way_5.jpg differ diff --git a/HeatUp/src/de/heatup/resources/images/ways/way_6.jpg b/HeatUp/src/de/heatup/resources/images/ways/way_6.jpg new file mode 100644 index 0000000..4bba8f9 Binary files /dev/null and b/HeatUp/src/de/heatup/resources/images/ways/way_6.jpg differ