mirror of
https://github.com/jokerx3/HeatUp
synced 2026-07-27 12:29:44 +02:00
Merge branch 'master' of github.com:jokerx3/prp
This commit is contained in:
@@ -1,5 +1,25 @@
|
||||
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.Scanner;
|
||||
|
||||
import javax.swing.JPanel;
|
||||
|
||||
import de.heatup.cfg.Config;
|
||||
import de.heatup.logging.Logger;
|
||||
import de.heatup.objects.*;
|
||||
@@ -234,4 +236,13 @@ public class MapEngine {
|
||||
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.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.Random;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
|
||||
import de.heatup.cfg.Config;
|
||||
|
||||
|
||||
public class ImageLoader {
|
||||
|
||||
@@ -20,10 +23,10 @@ public class ImageLoader {
|
||||
public static BufferedImage getBufferedImage(char key) {
|
||||
String imageFileName;
|
||||
switch (key) {
|
||||
case '#':
|
||||
case Config.wayChar:
|
||||
imageFileName="src/de/heatup/resources/images/25x25_black.png";
|
||||
break;
|
||||
case '-':
|
||||
case Config.wallChar:
|
||||
imageFileName="src/de/heatup/resources/images/25x25_wall_orange_2.png";
|
||||
break;
|
||||
case 'u':
|
||||
@@ -42,6 +45,19 @@ public class ImageLoader {
|
||||
imageFileName="src/de/heatup/resources/images/dummy_image.png";
|
||||
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;
|
||||
//System.out.println(imageFileName);
|
||||
try {
|
||||
@@ -57,5 +73,13 @@ public class ImageLoader {
|
||||
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.objects.StaticObject;
|
||||
import de.heatup.ui.KeyBindings;
|
||||
import de.heatup.ui.StatusPanelAdder;
|
||||
|
||||
|
||||
public class GameLoopD extends JFrame implements Runnable {
|
||||
@@ -56,20 +57,20 @@ public class GameLoopD extends JFrame implements Runnable {
|
||||
|
||||
outerPanel = new JPanel();
|
||||
outerPanel.setLayout(new BorderLayout());
|
||||
outerPanel.setVisible(true);
|
||||
outerPanel.setFocusable(false);
|
||||
|
||||
statusPanel = new JPanel();
|
||||
statusPanel.setLayout(new GridLayout(1,4));
|
||||
statusPanel.setPreferredSize(new Dimension(800,80));
|
||||
statusPanel.setFocusable(false);
|
||||
|
||||
gamePanel = new JPanel();
|
||||
gamePanel.setLayout(null);
|
||||
gamePanel.setPreferredSize(new Dimension(800,600));
|
||||
gamePanel.setVisible(true);
|
||||
|
||||
actionPanel = new JPanel();
|
||||
actionPanel.setLayout(new GridLayout(1,1));
|
||||
actionPanel.setPreferredSize(new Dimension(800,80));
|
||||
actionPanel.setFocusable(false);
|
||||
|
||||
|
||||
outerPanel.add(statusPanel,BorderLayout.NORTH);
|
||||
@@ -79,6 +80,10 @@ public class GameLoopD extends JFrame implements Runnable {
|
||||
frame.add(outerPanel);
|
||||
frame.pack();
|
||||
frame.setVisible(true);
|
||||
|
||||
// StatusPanel bauen
|
||||
StatusPanelAdder.setPanel(statusPanel);
|
||||
StatusPanelAdder.createPanel();
|
||||
|
||||
player01 = new Player();
|
||||
// Query.setPlayer(player01);
|
||||
@@ -104,9 +109,7 @@ public class GameLoopD extends JFrame implements Runnable {
|
||||
gamePanel.addKeyListener(kb);
|
||||
|
||||
MapEngine me = new MapEngine(1);
|
||||
for (StaticObject currentStaticObject : me.getAllMapObjects()) {
|
||||
gamePanel.add(currentStaticObject);
|
||||
}
|
||||
me.addAllToPanel(gamePanel);
|
||||
|
||||
Point spawnPoint = SpawnAssistant.getPathLocationOnGrid();
|
||||
player01.spawnAt(spawnPoint);
|
||||
@@ -118,6 +121,9 @@ public class GameLoopD extends JFrame implements Runnable {
|
||||
Point spawnPoint4 = SpawnAssistant.getPathLocationOnGrid();
|
||||
opponent03.spawnAt(spawnPoint4);
|
||||
|
||||
actionPanel.setVisible(true);
|
||||
outerPanel.setVisible(true);
|
||||
statusPanel.setVisible(true);
|
||||
gamePanel.setVisible(true);
|
||||
|
||||
//GameInterface.getGamePanel().repaint();
|
||||
@@ -184,7 +190,7 @@ public class GameLoopD extends JFrame implements Runnable {
|
||||
frames++;
|
||||
|
||||
try {
|
||||
thread.sleep(5); // entlastet die cpu massiv.
|
||||
thread.sleep(1); // entlastet die cpu massiv.
|
||||
|
||||
} catch (InterruptedException e) {
|
||||
// TODO Auto-generated catch block
|
||||
@@ -213,6 +219,11 @@ public class GameLoopD extends JFrame implements Runnable {
|
||||
// alles was animiert wird hier rein (paints)
|
||||
private void render() {
|
||||
player01.repaint();
|
||||
outerPanel.repaint();
|
||||
gamePanel.repaint();
|
||||
actionPanel.repaint();
|
||||
statusPanel.repaint();
|
||||
this.repaint();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,26 +1,30 @@
|
||||
package de.heatup.ui;
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Color;
|
||||
import java.awt.Dimension;
|
||||
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.JPanel;
|
||||
import javax.swing.JProgressBar;
|
||||
import javax.swing.SwingConstants;
|
||||
import javax.swing.border.LineBorder;
|
||||
|
||||
import de.heatup.testing.GameLoopD;
|
||||
import de.heatup.ui.statusPanel.Score;
|
||||
import de.heatup.ui.statusPanel.Temperature;
|
||||
import de.heatup.ui.statusPanel.Timer;
|
||||
|
||||
|
||||
public class StatusPanelAdder{
|
||||
Temperature temp;
|
||||
Score score;
|
||||
Timer timer;
|
||||
private Temperature temp;
|
||||
private Score score;
|
||||
private Timer timer;
|
||||
private static JPanel panel;
|
||||
|
||||
public int getTemp(){
|
||||
return temp.getTemp();
|
||||
@@ -32,34 +36,82 @@ public class StatusPanelAdder{
|
||||
return timer.getTime();
|
||||
}
|
||||
|
||||
public static void setPanel(JPanel newPanel){
|
||||
newPanel.setLayout(new FlowLayout());
|
||||
panel=newPanel;
|
||||
}
|
||||
|
||||
public static void createPanel(){
|
||||
JProgressBar tempbar= new JProgressBar(30,90);
|
||||
tempbar.setValue(45);
|
||||
//tempbar.setSize(new Dimension(200,50));
|
||||
|
||||
JLabel labelTemp= new JLabel("temperature");
|
||||
labelTemp.setFont(new Font("Arial", Font.CENTER_BASELINE, 16));
|
||||
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");
|
||||
scoreLabel.setBorder(new LineBorder(Color.BLACK, 2));
|
||||
//scoreLabel.setSize(new Dimension(100,50));
|
||||
//scoreLabel.setBorder(new LineBorder(Color.BLACK, 1));
|
||||
|
||||
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");
|
||||
powerUpLabel.setBorder(new LineBorder(Color.BLACK, 1));
|
||||
//powerUpLabel.setSize(new Dimension(200,50));
|
||||
|
||||
JLabel timeLabel = new JLabel();
|
||||
timeLabel.setBorder(new LineBorder(Color.BLACK, 2));
|
||||
timeLabel.setText("0");
|
||||
//timeLabel.setSize(new Dimension(300,24)); //Groesse,
|
||||
timeLabel.setHorizontalAlignment(SwingConstants.CENTER );
|
||||
//powerUpLabel.setBorder(new LineBorder(Color.BLACK, 1));
|
||||
JPanel powerUpPanel=new JPanel();
|
||||
powerUpPanel.setLayout(new BorderLayout());
|
||||
powerUpPanel.add(labelPowerUp, BorderLayout.NORTH);
|
||||
powerUpPanel.add(powerUpLabel, BorderLayout.SOUTH);
|
||||
|
||||
|
||||
|
||||
GameInterface.getStatusPanel().add(timeLabel);
|
||||
GameInterface.getStatusPanel().add(tempbar);
|
||||
GameInterface.getStatusPanel().add(scoreLabel);
|
||||
GameInterface.getStatusPanel().add(powerUpLabel);
|
||||
}
|
||||
private static void getStatusPanel(){
|
||||
GameInterface.getStatusPanel();
|
||||
}
|
||||
JLabel labelTime=new JLabel("Time");
|
||||
labelTime.setFont(new Font("Arial", Font.CENTER_BASELINE, 16));
|
||||
//labelTime.setBorder(new LineBorder(Color.BLACK, 1));
|
||||
labelTime.setSize(100,10);
|
||||
//labelTime.setHorizontalTextPosition(SwingConstants.CENTER);
|
||||
|
||||
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