mirror of
https://github.com/jokerx3/HeatUp
synced 2026-07-27 11:39:45 +02:00
Merge branch 'master' of github.com:jokerx3/prp
This commit is contained in:
@@ -0,0 +1,65 @@
|
|||||||
|
package de.heatup.ui;
|
||||||
|
|
||||||
|
import java.awt.Color;
|
||||||
|
import java.awt.Dimension;
|
||||||
|
import java.awt.FlowLayout;
|
||||||
|
|
||||||
|
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.ui.statusPanel.Score;
|
||||||
|
import de.heatup.ui.statusPanel.Temperature;
|
||||||
|
import de.heatup.ui.statusPanel.Timer;
|
||||||
|
|
||||||
|
|
||||||
|
public class StatusPanelAdder{
|
||||||
|
Temperature temp;
|
||||||
|
Score score;
|
||||||
|
Timer timer;
|
||||||
|
|
||||||
|
public int getTemp(){
|
||||||
|
return temp.getTemp();
|
||||||
|
}
|
||||||
|
public int getScore(){
|
||||||
|
return score.getScore();
|
||||||
|
}
|
||||||
|
public double getTime(){
|
||||||
|
return timer.getTime();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void createPanel(){
|
||||||
|
JProgressBar tempbar= new JProgressBar(30,90);
|
||||||
|
tempbar.setValue(45);
|
||||||
|
//tempbar.setSize(new Dimension(200,50));
|
||||||
|
|
||||||
|
JLabel scoreLabel= new JLabel("new Score Label");
|
||||||
|
scoreLabel.setBorder(new LineBorder(Color.BLACK, 2));
|
||||||
|
//scoreLabel.setSize(new Dimension(100,50));
|
||||||
|
|
||||||
|
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 );
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
GameInterface.getStatusPanel().add(timeLabel);
|
||||||
|
GameInterface.getStatusPanel().add(tempbar);
|
||||||
|
GameInterface.getStatusPanel().add(scoreLabel);
|
||||||
|
GameInterface.getStatusPanel().add(powerUpLabel);
|
||||||
|
}
|
||||||
|
private static void getStatusPanel(){
|
||||||
|
GameInterface.getStatusPanel();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
package de.heatup.ui.statusPanel;
|
||||||
|
|
||||||
|
|
||||||
|
public class Score {
|
||||||
|
private int score;
|
||||||
|
public Score(){
|
||||||
|
score=0;
|
||||||
|
}
|
||||||
|
//returns score
|
||||||
|
public int getScore(){
|
||||||
|
return score;
|
||||||
|
}
|
||||||
|
//resets score
|
||||||
|
public void resetScore(){
|
||||||
|
score=0;
|
||||||
|
}
|
||||||
|
//raises score
|
||||||
|
public void raiseScore(int additional){
|
||||||
|
score+=additional;
|
||||||
|
}
|
||||||
|
//reduces score; when score<0, score=0;
|
||||||
|
public void reduceScore(int reduce){
|
||||||
|
score-=reduce;
|
||||||
|
//when score less than 0
|
||||||
|
if (score<0){
|
||||||
|
score=0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,47 @@
|
|||||||
|
package de.heatup.ui.statusPanel;
|
||||||
|
|
||||||
|
|
||||||
|
public class Temperature {
|
||||||
|
private int min;
|
||||||
|
private int max;
|
||||||
|
private int valtemp;
|
||||||
|
|
||||||
|
//ggf. f�r Schwierigkeitsgerade min und max zu ver�ndern und startwert!?
|
||||||
|
public Temperature(int gmin, int gmax, int gtemp){
|
||||||
|
this.min=gmin;
|
||||||
|
this.max=gmax;
|
||||||
|
this.valtemp=gtemp;
|
||||||
|
}
|
||||||
|
|
||||||
|
//returns temp
|
||||||
|
public int getTemp(){
|
||||||
|
return valtemp;
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
* raiseTemp
|
||||||
|
* return true, gameplay goes on
|
||||||
|
* return false, heatup done
|
||||||
|
*/
|
||||||
|
public boolean raiseTemp(int additional){
|
||||||
|
valtemp+=additional;
|
||||||
|
if(valtemp>max){
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* reduceTemp
|
||||||
|
* return true; gameplay goes on
|
||||||
|
* return false; game over, temperature too low
|
||||||
|
*/
|
||||||
|
public boolean reduceTemp(int reduce){
|
||||||
|
valtemp-=reduce;
|
||||||
|
if (valtemp<min){
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
package de.heatup.ui.statusPanel;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
|
||||||
|
public class Timer {
|
||||||
|
|
||||||
|
static double elapsedTime = 0L;
|
||||||
|
public static void main(String[] args){
|
||||||
|
double startTime = System.currentTimeMillis();
|
||||||
|
|
||||||
|
//1s = 1000ms
|
||||||
|
while (elapsedTime <10000) {
|
||||||
|
|
||||||
|
elapsedTime = (new Date()).getTime() - startTime;
|
||||||
|
System.out.println(elapsedTime);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public double getTime(){
|
||||||
|
return elapsedTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
Reference in New Issue
Block a user