mirror of
https://github.com/jokerx3/HeatUp
synced 2026-07-27 11:49:44 +02:00
Wichtige Repaint änderung im Render
This commit is contained in:
@@ -1,5 +1,25 @@
|
|||||||
package de.heatup.highscore;
|
package de.heatup.highscore;
|
||||||
|
|
||||||
|
import de.heatup.cfg.Config;
|
||||||
|
import de.heatup.logging.Logger;
|
||||||
|
|
||||||
public class HighscoreHandler {
|
public class HighscoreHandler {
|
||||||
|
private static String currentMap;
|
||||||
|
private static MapHighscore currentMapHighscore;
|
||||||
|
/**
|
||||||
|
* Es muss vorher eine Karte geladen sein
|
||||||
|
*/
|
||||||
|
public HighscoreHandler() {
|
||||||
|
// if highscore does not exist
|
||||||
|
newMapHighscore();
|
||||||
|
// if it exists
|
||||||
|
// loadMapHighscore();
|
||||||
|
}
|
||||||
|
private static void newMapHighscore() {
|
||||||
|
currentMap = ChecksumGenerator.generateCheckSum(Config.mapFilePath);
|
||||||
|
currentMapHighscore = new MapHighscore();
|
||||||
|
Logger.write("HighscoreHandler - Map hashed: "+currentMap);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,6 +8,8 @@ import java.util.ArrayList;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Scanner;
|
import java.util.Scanner;
|
||||||
|
|
||||||
|
import javax.swing.JPanel;
|
||||||
|
|
||||||
import de.heatup.cfg.Config;
|
import de.heatup.cfg.Config;
|
||||||
import de.heatup.logging.Logger;
|
import de.heatup.logging.Logger;
|
||||||
import de.heatup.objects.*;
|
import de.heatup.objects.*;
|
||||||
@@ -234,4 +236,13 @@ public class MapEngine {
|
|||||||
System.out.println();
|
System.out.println();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* test
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public void addAllToPanel(JPanel gamePanel) {
|
||||||
|
for (StaticObject currentStaticObject : this.getAllMapObjects()) {
|
||||||
|
gamePanel.add(currentStaticObject);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,9 +3,12 @@ package de.heatup.objects;
|
|||||||
import java.awt.image.BufferedImage;
|
import java.awt.image.BufferedImage;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
import javax.imageio.ImageIO;
|
import javax.imageio.ImageIO;
|
||||||
|
|
||||||
|
import de.heatup.cfg.Config;
|
||||||
|
|
||||||
|
|
||||||
public class ImageLoader {
|
public class ImageLoader {
|
||||||
|
|
||||||
@@ -20,10 +23,10 @@ public class ImageLoader {
|
|||||||
public static BufferedImage getBufferedImage(char key) {
|
public static BufferedImage getBufferedImage(char key) {
|
||||||
String imageFileName;
|
String imageFileName;
|
||||||
switch (key) {
|
switch (key) {
|
||||||
case '#':
|
case Config.wayChar:
|
||||||
imageFileName="src/de/heatup/resources/images/25x25_black.png";
|
imageFileName="src/de/heatup/resources/images/25x25_black.png";
|
||||||
break;
|
break;
|
||||||
case '-':
|
case Config.wallChar:
|
||||||
imageFileName="src/de/heatup/resources/images/25x25_wall_orange_2.png";
|
imageFileName="src/de/heatup/resources/images/25x25_wall_orange_2.png";
|
||||||
break;
|
break;
|
||||||
case 'u':
|
case 'u':
|
||||||
@@ -42,6 +45,19 @@ public class ImageLoader {
|
|||||||
imageFileName="src/de/heatup/resources/images/dummy_image.png";
|
imageFileName="src/de/heatup/resources/images/dummy_image.png";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
if (isHardware(key)) {
|
||||||
|
Random rand = new Random();
|
||||||
|
switch (rand.nextInt(2)) {
|
||||||
|
case 0:
|
||||||
|
imageFileName="src/de/heatup/resources/images/hardware/rectangular_chip.jpg";
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
imageFileName="src/de/heatup/resources/images/hardware/square_chip.jpg";
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
BufferedImage loadedBufferedImage = null;
|
BufferedImage loadedBufferedImage = null;
|
||||||
//System.out.println(imageFileName);
|
//System.out.println(imageFileName);
|
||||||
try {
|
try {
|
||||||
@@ -57,5 +73,13 @@ public class ImageLoader {
|
|||||||
return loadedBufferedImage;
|
return loadedBufferedImage;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
private static boolean isHardware(char c) {
|
||||||
|
for (int i = Config.firstHardwareChar; i < Config.lastHardwareChar; i++) {
|
||||||
|
if (c == i) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -109,9 +109,7 @@ public class GameLoopD extends JFrame implements Runnable {
|
|||||||
gamePanel.addKeyListener(kb);
|
gamePanel.addKeyListener(kb);
|
||||||
|
|
||||||
MapEngine me = new MapEngine(1);
|
MapEngine me = new MapEngine(1);
|
||||||
for (StaticObject currentStaticObject : me.getAllMapObjects()) {
|
me.addAllToPanel(gamePanel);
|
||||||
gamePanel.add(currentStaticObject);
|
|
||||||
}
|
|
||||||
|
|
||||||
Point spawnPoint = SpawnAssistant.getPathLocationOnGrid();
|
Point spawnPoint = SpawnAssistant.getPathLocationOnGrid();
|
||||||
player01.spawnAt(spawnPoint);
|
player01.spawnAt(spawnPoint);
|
||||||
@@ -222,6 +220,7 @@ public class GameLoopD extends JFrame implements Runnable {
|
|||||||
gamePanel.repaint();
|
gamePanel.repaint();
|
||||||
actionPanel.repaint();
|
actionPanel.repaint();
|
||||||
statusPanel.repaint();
|
statusPanel.repaint();
|
||||||
|
this.repaint();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user