mirror of
https://github.com/jokerx3/HeatUp
synced 2026-07-27 11:39:45 +02:00
Kleinere Änderungen
This commit is contained in:
@@ -13,7 +13,7 @@ public class Logger {
|
|||||||
private static String logFile;
|
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")
|
@SuppressWarnings("resource")
|
||||||
public static void write(String s) {
|
public static void write(String s) {
|
||||||
|
|||||||
@@ -2,13 +2,14 @@ package de.heatup.mapengine;
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
import java.awt.Color;
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Scanner;
|
import java.util.Scanner;
|
||||||
|
|
||||||
import javax.swing.JPanel;
|
import javax.swing.JPanel;
|
||||||
|
|
||||||
|
import de.heatup.logging.Logger;
|
||||||
import de.heatup.objects.*;
|
import de.heatup.objects.*;
|
||||||
|
|
||||||
public class MapEngine {
|
public class MapEngine {
|
||||||
@@ -19,7 +20,7 @@ public class MapEngine {
|
|||||||
try {
|
try {
|
||||||
input = new Scanner(new File("src/de/heatup/resources/maps/map1.txt"));
|
input = new Scanner(new File("src/de/heatup/resources/maps/map1.txt"));
|
||||||
} catch (FileNotFoundException e) {
|
} catch (FileNotFoundException e) {
|
||||||
System.out.println("Konnte Map Datei nicht finden");
|
Logger.write("Konnte Map Datei nicht finden");
|
||||||
System.exit(-1);
|
System.exit(-1);
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
@@ -30,7 +31,6 @@ public class MapEngine {
|
|||||||
while (input.hasNextLine()) {
|
while (input.hasNextLine()) {
|
||||||
String currentLine = input.nextLine();
|
String currentLine = input.nextLine();
|
||||||
for (int i = 0; i<32; i++) {
|
for (int i = 0; i<32; i++) {
|
||||||
// tiles[lineCount][i] = defineTileType(currentLine.charAt(i));
|
|
||||||
tiles[lineCount][i] = currentLine.charAt(i);
|
tiles[lineCount][i] = currentLine.charAt(i);
|
||||||
}
|
}
|
||||||
lineCount++;
|
lineCount++;
|
||||||
@@ -55,10 +55,9 @@ public class MapEngine {
|
|||||||
public void addAllGameTilesToPanel(JPanel gamePanel) throws IOException {
|
public void addAllGameTilesToPanel(JPanel gamePanel) throws IOException {
|
||||||
int x = 0;
|
int x = 0;
|
||||||
int y = 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 i = 0; i<24; i++) {
|
||||||
for (int j = 0; j < 32; j++) {
|
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);
|
newGameTile.setPosition(x, y);
|
||||||
if (x+25 >= 800) {
|
if (x+25 >= 800) {
|
||||||
x = 0;
|
x = 0;
|
||||||
@@ -67,10 +66,16 @@ public class MapEngine {
|
|||||||
x += 25;
|
x += 25;
|
||||||
}
|
}
|
||||||
gamePanel.add(newGameTile.getLabel());
|
gamePanel.add(newGameTile.getLabel());
|
||||||
|
gamePanel.repaint();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
gamePanel.repaint();
|
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
* get all tiles in a 2 dimensional char array
|
||||||
|
*/
|
||||||
|
private char[][] getTiles() {
|
||||||
|
return tiles;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user