mirror of
https://github.com/jokerx3/HeatUp
synced 2026-07-27 10:19:46 +02:00
Merge branch 'master' of github.com:jokerx3/prp
This commit is contained in:
@@ -1,5 +1,25 @@
|
|||||||
package de.heatup.highscore;
|
package de.heatup.highscore;
|
||||||
|
|
||||||
public class HighscoreHandler {
|
import de.heatup.cfg.Config;
|
||||||
|
import de.heatup.logging.Logger;
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import de.heatup.mapengine.MapEngine;
|
|||||||
import de.heatup.mapengine.SpawnAssistant;
|
import de.heatup.mapengine.SpawnAssistant;
|
||||||
import de.heatup.objects.StaticObject;
|
import de.heatup.objects.StaticObject;
|
||||||
import de.heatup.ui.KeyBindings;
|
import de.heatup.ui.KeyBindings;
|
||||||
|
import de.heatup.ui.StatusPanelAdder;
|
||||||
|
|
||||||
|
|
||||||
public class GameLoopD extends JFrame implements Runnable {
|
public class GameLoopD extends JFrame implements Runnable {
|
||||||
@@ -56,20 +57,20 @@ public class GameLoopD extends JFrame implements Runnable {
|
|||||||
|
|
||||||
outerPanel = new JPanel();
|
outerPanel = new JPanel();
|
||||||
outerPanel.setLayout(new BorderLayout());
|
outerPanel.setLayout(new BorderLayout());
|
||||||
outerPanel.setVisible(true);
|
outerPanel.setFocusable(false);
|
||||||
|
|
||||||
statusPanel = new JPanel();
|
statusPanel = new JPanel();
|
||||||
statusPanel.setLayout(new GridLayout(1,4));
|
|
||||||
statusPanel.setPreferredSize(new Dimension(800,80));
|
statusPanel.setPreferredSize(new Dimension(800,80));
|
||||||
|
statusPanel.setFocusable(false);
|
||||||
|
|
||||||
gamePanel = new JPanel();
|
gamePanel = new JPanel();
|
||||||
gamePanel.setLayout(null);
|
gamePanel.setLayout(null);
|
||||||
gamePanel.setPreferredSize(new Dimension(800,600));
|
gamePanel.setPreferredSize(new Dimension(800,600));
|
||||||
gamePanel.setVisible(true);
|
|
||||||
|
|
||||||
actionPanel = new JPanel();
|
actionPanel = new JPanel();
|
||||||
actionPanel.setLayout(new GridLayout(1,1));
|
actionPanel.setLayout(new GridLayout(1,1));
|
||||||
actionPanel.setPreferredSize(new Dimension(800,80));
|
actionPanel.setPreferredSize(new Dimension(800,80));
|
||||||
|
actionPanel.setFocusable(false);
|
||||||
|
|
||||||
|
|
||||||
outerPanel.add(statusPanel,BorderLayout.NORTH);
|
outerPanel.add(statusPanel,BorderLayout.NORTH);
|
||||||
@@ -79,6 +80,10 @@ public class GameLoopD extends JFrame implements Runnable {
|
|||||||
frame.add(outerPanel);
|
frame.add(outerPanel);
|
||||||
frame.pack();
|
frame.pack();
|
||||||
frame.setVisible(true);
|
frame.setVisible(true);
|
||||||
|
|
||||||
|
// StatusPanel bauen
|
||||||
|
StatusPanelAdder.setPanel(statusPanel);
|
||||||
|
StatusPanelAdder.createPanel();
|
||||||
|
|
||||||
player01 = new Player();
|
player01 = new Player();
|
||||||
// Query.setPlayer(player01);
|
// Query.setPlayer(player01);
|
||||||
@@ -104,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);
|
||||||
@@ -118,6 +121,9 @@ public class GameLoopD extends JFrame implements Runnable {
|
|||||||
Point spawnPoint4 = SpawnAssistant.getPathLocationOnGrid();
|
Point spawnPoint4 = SpawnAssistant.getPathLocationOnGrid();
|
||||||
opponent03.spawnAt(spawnPoint4);
|
opponent03.spawnAt(spawnPoint4);
|
||||||
|
|
||||||
|
actionPanel.setVisible(true);
|
||||||
|
outerPanel.setVisible(true);
|
||||||
|
statusPanel.setVisible(true);
|
||||||
gamePanel.setVisible(true);
|
gamePanel.setVisible(true);
|
||||||
|
|
||||||
//GameInterface.getGamePanel().repaint();
|
//GameInterface.getGamePanel().repaint();
|
||||||
@@ -184,7 +190,7 @@ public class GameLoopD extends JFrame implements Runnable {
|
|||||||
frames++;
|
frames++;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
thread.sleep(5); // entlastet die cpu massiv.
|
thread.sleep(1); // entlastet die cpu massiv.
|
||||||
|
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
// TODO Auto-generated catch block
|
// TODO Auto-generated catch block
|
||||||
@@ -213,6 +219,11 @@ public class GameLoopD extends JFrame implements Runnable {
|
|||||||
// alles was animiert wird hier rein (paints)
|
// alles was animiert wird hier rein (paints)
|
||||||
private void render() {
|
private void render() {
|
||||||
player01.repaint();
|
player01.repaint();
|
||||||
|
outerPanel.repaint();
|
||||||
|
gamePanel.repaint();
|
||||||
|
actionPanel.repaint();
|
||||||
|
statusPanel.repaint();
|
||||||
|
this.repaint();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,26 +1,30 @@
|
|||||||
package de.heatup.ui;
|
package de.heatup.ui;
|
||||||
|
|
||||||
|
import java.awt.BorderLayout;
|
||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
import java.awt.Dimension;
|
|
||||||
import java.awt.FlowLayout;
|
import java.awt.FlowLayout;
|
||||||
|
import java.awt.Font;
|
||||||
|
import java.awt.GridBagConstraints;
|
||||||
|
import java.awt.GridLayout;
|
||||||
|
import java.awt.Insets;
|
||||||
|
|
||||||
import javax.swing.ImageIcon;
|
|
||||||
import javax.swing.JFrame;
|
|
||||||
import javax.swing.JLabel;
|
import javax.swing.JLabel;
|
||||||
import javax.swing.JPanel;
|
import javax.swing.JPanel;
|
||||||
import javax.swing.JProgressBar;
|
import javax.swing.JProgressBar;
|
||||||
import javax.swing.SwingConstants;
|
import javax.swing.SwingConstants;
|
||||||
import javax.swing.border.LineBorder;
|
import javax.swing.border.LineBorder;
|
||||||
|
|
||||||
|
import de.heatup.testing.GameLoopD;
|
||||||
import de.heatup.ui.statusPanel.Score;
|
import de.heatup.ui.statusPanel.Score;
|
||||||
import de.heatup.ui.statusPanel.Temperature;
|
import de.heatup.ui.statusPanel.Temperature;
|
||||||
import de.heatup.ui.statusPanel.Timer;
|
import de.heatup.ui.statusPanel.Timer;
|
||||||
|
|
||||||
|
|
||||||
public class StatusPanelAdder{
|
public class StatusPanelAdder{
|
||||||
Temperature temp;
|
private Temperature temp;
|
||||||
Score score;
|
private Score score;
|
||||||
Timer timer;
|
private Timer timer;
|
||||||
|
private static JPanel panel;
|
||||||
|
|
||||||
public int getTemp(){
|
public int getTemp(){
|
||||||
return temp.getTemp();
|
return temp.getTemp();
|
||||||
@@ -32,34 +36,82 @@ public class StatusPanelAdder{
|
|||||||
return timer.getTime();
|
return timer.getTime();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void setPanel(JPanel newPanel){
|
||||||
|
newPanel.setLayout(new FlowLayout());
|
||||||
|
panel=newPanel;
|
||||||
|
}
|
||||||
|
|
||||||
public static void createPanel(){
|
public static void createPanel(){
|
||||||
JProgressBar tempbar= new JProgressBar(30,90);
|
JLabel labelTemp= new JLabel("temperature");
|
||||||
tempbar.setValue(45);
|
labelTemp.setFont(new Font("Arial", Font.CENTER_BASELINE, 16));
|
||||||
//tempbar.setSize(new Dimension(200,50));
|
labelTemp.setBorder(new LineBorder(Color.BLACK, 1));
|
||||||
|
|
||||||
|
JProgressBar tempBar= new JProgressBar(30,90);
|
||||||
|
tempBar.setValue(45);
|
||||||
|
|
||||||
|
JPanel tempPanel=new JPanel();
|
||||||
|
tempPanel.setLayout(new BorderLayout());
|
||||||
|
tempPanel.add(labelTemp, BorderLayout.NORTH);
|
||||||
|
tempPanel.add(tempBar, BorderLayout.SOUTH);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
JLabel labelScore= new JLabel("score");
|
||||||
|
labelScore.setFont(new Font("Arial", Font.CENTER_BASELINE, 16));
|
||||||
|
//labelScore.setBorder(new LineBorder(Color.BLACK, 1));
|
||||||
|
|
||||||
JLabel scoreLabel= new JLabel("new Score Label");
|
JLabel scoreLabel= new JLabel("new Score Label");
|
||||||
scoreLabel.setBorder(new LineBorder(Color.BLACK, 2));
|
//scoreLabel.setBorder(new LineBorder(Color.BLACK, 1));
|
||||||
//scoreLabel.setSize(new Dimension(100,50));
|
|
||||||
|
JPanel scorePanel=new JPanel();
|
||||||
|
scorePanel.setLayout(new BorderLayout());
|
||||||
|
scorePanel.add(labelScore, BorderLayout.NORTH);
|
||||||
|
scorePanel.add(scoreLabel, BorderLayout.SOUTH);
|
||||||
|
|
||||||
|
|
||||||
|
JLabel labelPowerUp = new JLabel("PowerUp");
|
||||||
|
labelPowerUp.setFont(new Font("Arial", Font.CENTER_BASELINE, 16));
|
||||||
|
//labelPowerUp.setBorder(new LineBorder(Color.BLACK, 1));
|
||||||
|
|
||||||
JLabel powerUpLabel = new JLabel(/*new ImageIcon("path_to_image.png")*/"powerUpLabel");
|
JLabel powerUpLabel = new JLabel(/*new ImageIcon("path_to_image.png")*/"powerUpLabel");
|
||||||
powerUpLabel.setBorder(new LineBorder(Color.BLACK, 1));
|
//powerUpLabel.setBorder(new LineBorder(Color.BLACK, 1));
|
||||||
//powerUpLabel.setSize(new Dimension(200,50));
|
JPanel powerUpPanel=new JPanel();
|
||||||
|
powerUpPanel.setLayout(new BorderLayout());
|
||||||
JLabel timeLabel = new JLabel();
|
powerUpPanel.add(labelPowerUp, BorderLayout.NORTH);
|
||||||
timeLabel.setBorder(new LineBorder(Color.BLACK, 2));
|
powerUpPanel.add(powerUpLabel, BorderLayout.SOUTH);
|
||||||
timeLabel.setText("0");
|
|
||||||
//timeLabel.setSize(new Dimension(300,24)); //Groesse,
|
|
||||||
timeLabel.setHorizontalAlignment(SwingConstants.CENTER );
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
GameInterface.getStatusPanel().add(timeLabel);
|
JLabel labelTime=new JLabel("Time");
|
||||||
GameInterface.getStatusPanel().add(tempbar);
|
labelTime.setFont(new Font("Arial", Font.CENTER_BASELINE, 16));
|
||||||
GameInterface.getStatusPanel().add(scoreLabel);
|
//labelTime.setBorder(new LineBorder(Color.BLACK, 1));
|
||||||
GameInterface.getStatusPanel().add(powerUpLabel);
|
labelTime.setSize(100,10);
|
||||||
}
|
//labelTime.setHorizontalTextPosition(SwingConstants.CENTER);
|
||||||
private static void getStatusPanel(){
|
|
||||||
GameInterface.getStatusPanel();
|
JLabel timeLabel = new JLabel("123456789");
|
||||||
}
|
//timeLabel.setBorder(new LineBorder(Color.BLACK, 1));
|
||||||
|
timeLabel.setFont(new Font("Arial", Font.ITALIC, 12));
|
||||||
|
|
||||||
|
JPanel timePanel=new JPanel();
|
||||||
|
timePanel.setLayout(new BorderLayout());
|
||||||
|
timePanel.add(labelTime, BorderLayout.NORTH);
|
||||||
|
timePanel.add(timeLabel, BorderLayout.SOUTH);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
panel.add(timePanel);
|
||||||
|
panel.add(scorePanel);
|
||||||
|
panel.add(tempPanel);
|
||||||
|
panel.add(powerUpPanel);
|
||||||
|
|
||||||
|
panel.setVisible(false);
|
||||||
|
panel.setVisible(true);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user