StatusPanel Package hinzugefügt; statusPanel dateien hochgeladen

This commit is contained in:
feschi55
2014-11-04 11:47:07 +01:00
parent 005c43168b
commit f92e46f1c5
4 changed files with 169 additions and 0 deletions
@@ -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. fr Schwierigkeitsgerade min und max zu verndern 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;
}
}