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:
@@ -26,6 +26,9 @@ public class ImageLoader {
|
|||||||
case Config.wallChar:
|
case Config.wallChar:
|
||||||
imageFileName="de/heatup/resources/images/25x25_wall_orange_2.png";
|
imageFileName="de/heatup/resources/images/25x25_wall_orange_2.png";
|
||||||
break;
|
break;
|
||||||
|
case 'b':
|
||||||
|
imageFileName="de/heatup/resources/images/25x25_powerup.png";
|
||||||
|
break;
|
||||||
case 'u':
|
case 'u':
|
||||||
imageFileName="de/heatup/resources/images/little_green_guy_verysmall.png";
|
imageFileName="de/heatup/resources/images/little_green_guy_verysmall.png";
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -1,75 +1,68 @@
|
|||||||
package de.heatup.objects;
|
package de.heatup.objects;
|
||||||
|
|
||||||
import java.awt.BasicStroke;
|
|
||||||
import java.awt.Graphics;
|
|
||||||
import java.awt.Graphics2D;
|
|
||||||
import java.awt.Point;
|
import java.awt.Point;
|
||||||
import java.awt.RenderingHints;
|
|
||||||
import java.awt.image.BufferedImage;
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
import javax.imageio.ImageIO;
|
import de.heatup.ui.PanelBuilder;
|
||||||
import javax.swing.JComponent;
|
import de.heatup.ui.StatusPanelAdder;
|
||||||
|
|
||||||
import de.heatup.cfg.Config;
|
public class PowerUp extends StaticObject {
|
||||||
import de.heatup.logging.Logger;
|
|
||||||
import de.heatup.mapengine.CollisionHandler;
|
|
||||||
|
|
||||||
public class PowerUp extends JComponent {
|
/**
|
||||||
|
* Warum auch immer ist JComponent per default serialisierbar
|
||||||
|
*/
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
protected BufferedImage bf1;
|
|
||||||
protected Graphics2D g2d;
|
private int pType;
|
||||||
private Point currentGridPosition;
|
private boolean triggered = false;
|
||||||
private int type;
|
private boolean triggeredByPlayer = false;
|
||||||
|
|
||||||
|
private static int tickCount = 0;
|
||||||
|
private static int tickRoundMax = 10000;
|
||||||
|
private static int resetTickstamp = 0;
|
||||||
|
|
||||||
public PowerUp() {
|
public PowerUp() {
|
||||||
|
super('b', new Point());
|
||||||
Random rand = new Random();
|
Random rand = new Random();
|
||||||
CollisionHandler.addPowerUpObject(this);
|
this.pType = rand.nextInt(2);
|
||||||
this.type = rand.nextInt(3);
|
StatusPanelAdder.setPUText(""+pType);
|
||||||
}
|
}
|
||||||
|
public void spawnAt(Point spawnPoint) {
|
||||||
public void setGridLocation(int x, int y) {
|
this.currentGridPosition = spawnPoint;
|
||||||
currentGridPosition.setLocation(x, y);
|
super.setAutoBounds(spawnPoint.x*25, spawnPoint.y*25);
|
||||||
|
PanelBuilder.getGamePanel().setComponentZOrder(this, 1);
|
||||||
|
this.repaint();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Point getGridLocation() {
|
public Point getGridLocation() {
|
||||||
return currentGridPosition;
|
return currentGridPosition;
|
||||||
}
|
}
|
||||||
|
public void kill() {
|
||||||
public void paintComponent(Graphics g) {
|
StatusPanelAdder.setPUText(" ");
|
||||||
g2d = (Graphics2D) g;
|
PanelBuilder.getGamePanel().remove(this);
|
||||||
if (bf1 == null) {
|
PanelBuilder.getGamePanel().repaint();
|
||||||
loadBufferedImage();
|
|
||||||
}
|
}
|
||||||
|
public boolean isTriggered() {
|
||||||
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
|
return triggered;
|
||||||
g2d.drawImage(bf1, 0, 0, this);
|
|
||||||
g2d.setStroke(new BasicStroke(8.0f));
|
|
||||||
g2d.finalize();
|
|
||||||
}
|
}
|
||||||
|
public void tick() {
|
||||||
public void spawnAt(Point spawnPoint) {
|
tickCount++;
|
||||||
this.currentGridPosition = spawnPoint;
|
if (tickCount>=tickRoundMax) {
|
||||||
this.setAutoBounds(spawnPoint.x*25, spawnPoint.y*25);
|
tickCount = 0;
|
||||||
this.repaint();
|
|
||||||
}
|
}
|
||||||
|
if (this.isTriggered() && tickCount == resetTickstamp) {
|
||||||
protected void loadBufferedImage() {
|
PowerUpController.deactivate(pType, triggeredByPlayer);
|
||||||
try {
|
PowerUpHandler.removePowerUp();
|
||||||
this.bf1 = ImageIO.read(new File("src/de/heatup/resources/images/powerup.png"));
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
public void trigger(boolean byPlayer) {
|
||||||
|
this.triggered = true;
|
||||||
|
this.triggeredByPlayer = byPlayer;
|
||||||
|
resetTickstamp = tickCount+60*(PowerUpController.getDuration(pType));
|
||||||
|
resetTickstamp = PowerUpHandler.checkStamp(resetTickstamp);
|
||||||
|
PowerUpController.activate(pType, byPlayer);
|
||||||
|
|
||||||
public void setImage(BufferedImage image) {
|
|
||||||
this.bf1 = image;
|
|
||||||
}
|
}
|
||||||
|
public void setRemainingTime(int time) {
|
||||||
public void setAutoBounds(int x, int y) {
|
StatusPanelAdder.setPUText(pType+" "+time);
|
||||||
this.setBounds(x, y, this.bf1.getWidth(), this.bf1.getHeight());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,81 @@
|
|||||||
package de.heatup.objects;
|
package de.heatup.objects;
|
||||||
|
|
||||||
public class PowerUpHandler {
|
import java.awt.Point;
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
|
import de.heatup.logging.Logger;
|
||||||
|
import de.heatup.mapengine.SpawnAssistant;
|
||||||
|
import de.heatup.ui.PanelBuilder;
|
||||||
|
|
||||||
|
public class PowerUpHandler {
|
||||||
|
private static boolean puSpawned = false;
|
||||||
|
private static boolean firstRound = true;
|
||||||
|
private static int tickCount = 0;
|
||||||
|
private static int tickRoundMax = 10000;
|
||||||
|
private static int resetTickstamp = 0;
|
||||||
|
private static PowerUp pu = null;
|
||||||
|
private static Random rand = new Random();
|
||||||
|
public static void tick() {
|
||||||
|
tickCount++;
|
||||||
|
if (tickCount>=tickRoundMax) {
|
||||||
|
tickCount = 0;
|
||||||
|
}
|
||||||
|
if (puSpawned) {
|
||||||
|
int remainingTicks;
|
||||||
|
if (tickCount > resetTickstamp) {
|
||||||
|
remainingTicks = tickRoundMax - tickCount + resetTickstamp;
|
||||||
|
} else {
|
||||||
|
remainingTicks = resetTickstamp - tickCount;
|
||||||
|
}
|
||||||
|
pu.setRemainingTime(remainingTicks/60);
|
||||||
|
if (pu.isTriggered()) {
|
||||||
|
pu.tick();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!firstRound) {
|
||||||
|
if (tickCount == resetTickstamp && !puSpawned) {
|
||||||
|
createPowerUp();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (tickCount == resetTickstamp && puSpawned) {
|
||||||
|
if (!pu.isTriggered()) {
|
||||||
|
removePowerUp();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
firstRound = false;
|
||||||
|
resetTickstamp = tickCount+60*(rand.nextInt(10)+15);
|
||||||
|
resetTickstamp = checkStamp(resetTickstamp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
protected static int checkStamp(int stamp) {
|
||||||
|
if (stamp > tickRoundMax) {
|
||||||
|
return stamp % tickRoundMax;
|
||||||
|
} else {
|
||||||
|
return stamp;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public static void createPowerUp() {
|
||||||
|
Point sp = SpawnAssistant.getPathLocationOnGrid();
|
||||||
|
pu = new PowerUp();
|
||||||
|
pu.setBounds(25, 25, 25, 25);
|
||||||
|
PanelBuilder.getGamePanel().add(pu);
|
||||||
|
pu.spawnAt(sp);
|
||||||
|
resetTickstamp = tickCount+60*(rand.nextInt(15)+15);
|
||||||
|
resetTickstamp = checkStamp(resetTickstamp);
|
||||||
|
puSpawned = true;
|
||||||
|
}
|
||||||
|
public static void removePowerUp() {
|
||||||
|
pu.kill();
|
||||||
|
pu = null;
|
||||||
|
resetTickstamp = tickCount+60*(rand.nextInt(15)+15);
|
||||||
|
resetTickstamp = checkStamp(resetTickstamp);
|
||||||
|
puSpawned = false;
|
||||||
|
}
|
||||||
|
public static PowerUp getPowerUp() {
|
||||||
|
if (pu == null) {
|
||||||
|
return new PowerUp();
|
||||||
|
} else
|
||||||
|
return pu;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ public class FontLoader {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Font getFont(){
|
public static Font getFont(){
|
||||||
return ttfBase;
|
return ttfBase;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ import de.heatup.objects.ImageLoader;
|
|||||||
import de.heatup.objects.InstancedObjects;
|
import de.heatup.objects.InstancedObjects;
|
||||||
import de.heatup.objects.Opponent;
|
import de.heatup.objects.Opponent;
|
||||||
import de.heatup.objects.Player;
|
import de.heatup.objects.Player;
|
||||||
|
import de.heatup.objects.PowerUpHandler;
|
||||||
import de.heatup.timers.HardwareResetTimers;
|
import de.heatup.timers.HardwareResetTimers;
|
||||||
import de.heatup.ui.actionPanel.ActionControl;
|
import de.heatup.ui.actionPanel.ActionControl;
|
||||||
import de.heatup.ui.actionPanel.ActionWatcher;
|
import de.heatup.ui.actionPanel.ActionWatcher;
|
||||||
@@ -82,6 +83,11 @@ public class PanelBuilder {
|
|||||||
StatusPanelAdder.tick();
|
StatusPanelAdder.tick();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
EventQueue.invokeLater(new Runnable() {
|
||||||
|
@Override public void run() {
|
||||||
|
PowerUpHandler.tick();
|
||||||
|
}
|
||||||
|
});
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
Logger.write("Invalid gameState");
|
Logger.write("Invalid gameState");
|
||||||
@@ -108,6 +114,9 @@ public class PanelBuilder {
|
|||||||
createGame(1); /* wird eigentlich vom menue aufgerufen */
|
createGame(1); /* wird eigentlich vom menue aufgerufen */
|
||||||
|
|
||||||
}
|
}
|
||||||
|
public static JPanel getGamePanel() {
|
||||||
|
return gamePanel;
|
||||||
|
}
|
||||||
private static void createGame(int map) {
|
private static void createGame(int map) {
|
||||||
|
|
||||||
instancedObjects = new InstancedObjects();
|
instancedObjects = new InstancedObjects();
|
||||||
|
|||||||
@@ -29,20 +29,24 @@ public class StatusPanelAdder{
|
|||||||
private static double tempPlus=0.0;
|
private static double tempPlus=0.0;
|
||||||
private static double tempMinus=0.0;
|
private static double tempMinus=0.0;
|
||||||
private static double barSpeed=0.01;
|
private static double barSpeed=0.01;
|
||||||
|
private static float red;
|
||||||
|
private static float green;
|
||||||
|
private static float blue;
|
||||||
private static boolean ende=false;
|
private static boolean ende=false;
|
||||||
private static JLabel labelTempC= new JLabel("§");
|
private static JLabel labelTempC= new JLabel("§");
|
||||||
private static JLabel labelTemp= new JLabel("temperature");
|
private static JLabel labelTemp= new JLabel("temperature");
|
||||||
private static JProgressBar tempBar;
|
private static JProgressBar tempBar;
|
||||||
private static JLabel labelScore= new JLabel("score");
|
private static JLabel labelScore= new JLabel("score");
|
||||||
private static JLabel scoreLabel= new JLabel("new Score Label");
|
private static JLabel scoreLabel= new JLabel(" ");
|
||||||
private static JLabel labelPowerUp = new JLabel("PowerUp");
|
private static JLabel labelPowerUp = new JLabel("PowerUp");
|
||||||
private static JLabel powerUpLabel = new JLabel(/*new ImageIcon("path_to_image.png")*/"powerUpLabel");
|
private static JLabel powerUpLabel = new JLabel(" ");
|
||||||
private static JLabel labelTime=new JLabel("Time");
|
private static JLabel labelTime=new JLabel("Time");
|
||||||
private static JLabel timeLabel = new JLabel("0");
|
private static JLabel timeLabel = new JLabel("0");
|
||||||
private static Font emulogicheading;
|
private static Font emulogicheading;
|
||||||
private static Font emulogictext;
|
private static Font emulogictext;
|
||||||
private static Font ttfBase;
|
private static Font ttfBase;
|
||||||
private static FontLoader fl=new FontLoader();
|
private static FontLoader fl=new FontLoader();
|
||||||
|
private static Color tempBarColor= new Color(0,0,255);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -73,6 +77,9 @@ public class StatusPanelAdder{
|
|||||||
newPanel.setLayout(new FlowLayout(FlowLayout.CENTER, hgap,5));
|
newPanel.setLayout(new FlowLayout(FlowLayout.CENTER, hgap,5));
|
||||||
panel=newPanel;
|
panel=newPanel;
|
||||||
}
|
}
|
||||||
|
public static void setPUText(String s){
|
||||||
|
powerUpLabel.setText(s);
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* erhöht die Anzahl Manipulationen
|
* erhöht die Anzahl Manipulationen
|
||||||
*/
|
*/
|
||||||
@@ -96,7 +103,7 @@ public class StatusPanelAdder{
|
|||||||
timeLabel.setText(Timer.getMinuteS() + ":" + Timer.getSecondsS());
|
timeLabel.setText(Timer.getMinuteS() + ":" + Timer.getSecondsS());
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Temperaturbearbeitung
|
* Temperaturaktualisierung
|
||||||
*/
|
*/
|
||||||
labelTempC.setText(tempBar.getValue() + "°C");
|
labelTempC.setText(tempBar.getValue() + "°C");
|
||||||
temping=0;
|
temping=0;
|
||||||
@@ -115,6 +122,14 @@ public class StatusPanelAdder{
|
|||||||
tempPlus=-1;
|
tempPlus=-1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
red=((float)(((tempBar.getValue())-30)/80.0));
|
||||||
|
blue=(1-red);
|
||||||
|
tempBarColor=new Color(red, green,blue, (float)0.525);
|
||||||
|
tempBar.setForeground(tempBarColor);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (temping!=0){
|
if (temping!=0){
|
||||||
Logger.write("Temperatur: " + tempBar.getValue());
|
Logger.write("Temperatur: " + tempBar.getValue());
|
||||||
@@ -138,7 +153,7 @@ public class StatusPanelAdder{
|
|||||||
* fügt dem der Klasse übergebenen Panel Objekte hinzu & formatiert diese
|
* fügt dem der Klasse übergebenen Panel Objekte hinzu & formatiert diese
|
||||||
*/
|
*/
|
||||||
public static void createPanel(){
|
public static void createPanel(){
|
||||||
ttfBase=fl.getFont();
|
ttfBase=FontLoader.getFont();
|
||||||
emulogicheading = ttfBase.deriveFont(Font.PLAIN, 16);
|
emulogicheading = ttfBase.deriveFont(Font.PLAIN, 16);
|
||||||
emulogictext= ttfBase.deriveFont(Font.PLAIN, 12);
|
emulogictext= ttfBase.deriveFont(Font.PLAIN, 12);
|
||||||
|
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import java.awt.Font;
|
|||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
|
|
||||||
import de.heatup.mapengine.MapGrid;
|
import de.heatup.mapengine.MapGrid;
|
||||||
|
import de.heatup.ui.FontLoader;
|
||||||
import de.heatup.ui.Main;
|
import de.heatup.ui.Main;
|
||||||
|
|
||||||
public class ActionControl{
|
public class ActionControl{
|
||||||
@@ -22,15 +23,25 @@ public class ActionControl{
|
|||||||
private static JLabel bigActionLabel;
|
private static JLabel bigActionLabel;
|
||||||
private static int tmpCount=0;
|
private static int tmpCount=0;
|
||||||
private static boolean keyA=true;
|
private static boolean keyA=true;
|
||||||
|
private static Font ttfBase=FontLoader.getFont();
|
||||||
|
private static Font emulogicaction;
|
||||||
|
private static Font emulogicbigaction;
|
||||||
|
|
||||||
public static void setPanel(JPanel newPanel){
|
public static void setPanel(JPanel newPanel){
|
||||||
|
emulogicaction = ttfBase.deriveFont(Font.PLAIN, 12);
|
||||||
|
emulogicbigaction= ttfBase.deriveFont(Font.LAYOUT_RIGHT_TO_LEFT, 25);
|
||||||
|
|
||||||
panel = newPanel;
|
panel = newPanel;
|
||||||
|
panel.setBackground(Color.BLACK);
|
||||||
actionLabel = new JLabel();
|
actionLabel = new JLabel();
|
||||||
bigActionLabel = new JLabel();
|
bigActionLabel = new JLabel();
|
||||||
bar = new JProgressBar();
|
bar = new JProgressBar();
|
||||||
actionLabel.setFont(new Font("Arial", Font.CENTER_BASELINE, 16));
|
//actionLabel.setFont(new Font("Arial", Font.CENTER_BASELINE, 16));
|
||||||
|
actionLabel.setFont(emulogicaction);
|
||||||
actionLabel.setHorizontalAlignment(JLabel.CENTER);
|
actionLabel.setHorizontalAlignment(JLabel.CENTER);
|
||||||
bigActionLabel.setFont(new Font("Arial", Font.LAYOUT_RIGHT_TO_LEFT,40));
|
actionLabel.setForeground(Color.YELLOW);
|
||||||
|
//bigActionLabel.setFont(new Font("Arial", Font.LAYOUT_RIGHT_TO_LEFT,40));
|
||||||
|
bigActionLabel.setFont(emulogicbigaction);
|
||||||
bigActionLabel.setForeground(Color.RED);
|
bigActionLabel.setForeground(Color.RED);
|
||||||
bigActionLabel.setHorizontalAlignment(JLabel.CENTER);
|
bigActionLabel.setHorizontalAlignment(JLabel.CENTER);
|
||||||
bigActionLabel.setVisible(false);
|
bigActionLabel.setVisible(false);
|
||||||
@@ -46,7 +57,7 @@ public class ActionControl{
|
|||||||
if(rd==1){
|
if(rd==1){
|
||||||
option=1;
|
option=1;
|
||||||
setSmash(new Smashing().getKey());
|
setSmash(new Smashing().getKey());
|
||||||
String str= "Bitte die Taste "+getSmash()+" so schnell wie moeglich druecken";
|
String str= "Bitte die Taste --"+getSmash()+"-- so schnell wie moeglich druecken";
|
||||||
actionLabel.setText(str);
|
actionLabel.setText(str);
|
||||||
setProgressBar(0);
|
setProgressBar(0);
|
||||||
beforTime=System.nanoTime();
|
beforTime=System.nanoTime();
|
||||||
|
|||||||
Reference in New Issue
Block a user