From 2f432346ce3d83b18635efa485f853a7018b1dd5 Mon Sep 17 00:00:00 2001 From: toksikk Date: Fri, 31 Oct 2014 14:16:20 +0100 Subject: [PATCH] =?UTF-8?q?Kleinere=20=C3=84nderungen?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- HeatUp/src/de/heatup/logging/Logger.java | 2 +- HeatUp/src/de/heatup/mapengine/MapEngine.java | 19 ++++++++++++------- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/HeatUp/src/de/heatup/logging/Logger.java b/HeatUp/src/de/heatup/logging/Logger.java index 4f0b341..ea429cf 100644 --- a/HeatUp/src/de/heatup/logging/Logger.java +++ b/HeatUp/src/de/heatup/logging/Logger.java @@ -13,7 +13,7 @@ public class Logger { private static String logFile; /* - * writes a new log line to cmd via System.out.println() and/or (if enabled) appends a new line to a log file + * writes a new log line to commandline/shell via System.out.println() and/or (if enabled) appends a new line to a log file */ @SuppressWarnings("resource") public static void write(String s) { diff --git a/HeatUp/src/de/heatup/mapengine/MapEngine.java b/HeatUp/src/de/heatup/mapengine/MapEngine.java index 27087a9..3d8d125 100644 --- a/HeatUp/src/de/heatup/mapengine/MapEngine.java +++ b/HeatUp/src/de/heatup/mapengine/MapEngine.java @@ -2,13 +2,14 @@ package de.heatup.mapengine; -import java.awt.Color; import java.io.File; import java.io.FileNotFoundException; import java.io.IOException; import java.util.Scanner; + import javax.swing.JPanel; +import de.heatup.logging.Logger; import de.heatup.objects.*; public class MapEngine { @@ -19,7 +20,7 @@ public class MapEngine { try { input = new Scanner(new File("src/de/heatup/resources/maps/map1.txt")); } catch (FileNotFoundException e) { - System.out.println("Konnte Map Datei nicht finden"); + Logger.write("Konnte Map Datei nicht finden"); System.exit(-1); e.printStackTrace(); } @@ -30,7 +31,6 @@ public class MapEngine { while (input.hasNextLine()) { String currentLine = input.nextLine(); for (int i = 0; i<32; i++) { -// tiles[lineCount][i] = defineTileType(currentLine.charAt(i)); tiles[lineCount][i] = currentLine.charAt(i); } lineCount++; @@ -55,10 +55,9 @@ public class MapEngine { public void addAllGameTilesToPanel(JPanel gamePanel) throws IOException { int x = 0; int y = 0; - gamePanel.setBackground(new Color(500)); // hintergrund gamepanel auf blau setzen, bitte entfernen, ist unnötig for (int i = 0; i<24; i++) { for (int j = 0; j < 32; j++) { - Objekt newGameTile = new Objekt(tiles[i][j]); + Objekt newGameTile = new Objekt(getTiles()[i][j]); newGameTile.setPosition(x, y); if (x+25 >= 800) { x = 0; @@ -67,10 +66,16 @@ public class MapEngine { x += 25; } gamePanel.add(newGameTile.getLabel()); - + gamePanel.repaint(); } } - gamePanel.repaint(); + + } + /* + * get all tiles in a 2 dimensional char array + */ + private char[][] getTiles() { + return tiles; } }