mirror of
https://github.com/jokerx3/HeatUp
synced 2026-07-27 09:59:45 +02:00
Score Anzeige und Berechnung, Timer angefangen
This commit is contained in:
@@ -18,15 +18,14 @@ import de.heatup.ui.statusPanel.Timer;
|
|||||||
|
|
||||||
|
|
||||||
public class StatusPanelAdder{
|
public class StatusPanelAdder{
|
||||||
private Score score;
|
|
||||||
private Timer timer;
|
|
||||||
private static JPanel panel;
|
private static JPanel panel;
|
||||||
private static int hgap=30;
|
private static int hgap=30;
|
||||||
private static int vgap=9;
|
private static int vgap=9;
|
||||||
private static int modifier=-1;
|
private static int modifier=-1;
|
||||||
|
private static int temping=0;
|
||||||
|
private static int manipulations=0;
|
||||||
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 int temping=0;
|
|
||||||
private static double barSpeed=0.01;
|
private static double barSpeed=0.01;
|
||||||
private static boolean ende=false;
|
private static boolean ende=false;
|
||||||
private static JLabel labelTempC= new JLabel("§");
|
private static JLabel labelTempC= new JLabel("§");
|
||||||
@@ -37,7 +36,7 @@ public class StatusPanelAdder{
|
|||||||
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(/*new ImageIcon("path_to_image.png")*/"powerUpLabel");
|
||||||
private static JLabel labelTime=new JLabel("Time");
|
private static JLabel labelTime=new JLabel("Time");
|
||||||
private static JLabel timeLabel = new JLabel("123456789");
|
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;
|
||||||
@@ -73,20 +72,32 @@ public class StatusPanelAdder{
|
|||||||
|
|
||||||
}
|
}
|
||||||
public int getScore(){
|
public int getScore(){
|
||||||
return score.getScore();
|
return Score.getScore();
|
||||||
}
|
|
||||||
public double getTime(){
|
|
||||||
return timer.getTime();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param newPanel das zu verwendende Panel zur Bearbeitung
|
||||||
|
*/
|
||||||
public static void setPanel(JPanel newPanel){
|
public static void setPanel(JPanel newPanel){
|
||||||
newPanel.setLayout(new FlowLayout(FlowLayout.CENTER, hgap,5));
|
newPanel.setLayout(new FlowLayout(FlowLayout.CENTER, hgap,5));
|
||||||
panel=newPanel;
|
panel=newPanel;
|
||||||
}
|
}
|
||||||
|
public static void addManipulations(){
|
||||||
|
manipulations+=1;
|
||||||
|
Score.raiseScore(25);
|
||||||
|
}
|
||||||
|
public static int getManipulations(){
|
||||||
|
return manipulations;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public static void tick() {
|
public static void tick() {
|
||||||
|
Timer.tickTimer();
|
||||||
|
timeLabel.setText(Timer.getMinuteS() + ":" + Timer.getSecondsS());
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Temperaturbearbeitung
|
||||||
|
*/
|
||||||
labelTempC.setText(tempBar.getValue() + "°C");
|
labelTempC.setText(tempBar.getValue() + "°C");
|
||||||
temping=0;
|
temping=0;
|
||||||
if (modifier<0){
|
if (modifier<0){
|
||||||
@@ -123,7 +134,9 @@ public class StatusPanelAdder{
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* fügt dem der Klasse übergebenen Panel Objekte hinzu & formatiert diese
|
||||||
|
*/
|
||||||
public static void createPanel(){
|
public static void createPanel(){
|
||||||
implementFont();
|
implementFont();
|
||||||
emulogicheading = ttfBase.deriveFont(Font.PLAIN, 16);
|
emulogicheading = ttfBase.deriveFont(Font.PLAIN, 16);
|
||||||
|
|||||||
@@ -1,35 +1,66 @@
|
|||||||
package de.heatup.ui.statusPanel;
|
package de.heatup.ui.statusPanel;
|
||||||
|
|
||||||
|
import de.heatup.ui.StatusPanelAdder;
|
||||||
|
|
||||||
|
|
||||||
public class Score {
|
public class Score {
|
||||||
private int score;
|
private static int score;
|
||||||
public Score(){
|
private static int bonusTime=180;
|
||||||
score=0;
|
/**
|
||||||
}
|
* @return Score
|
||||||
//returns score
|
*/
|
||||||
public int getScore(){
|
public static int getScore(){
|
||||||
return score;
|
return score;
|
||||||
}
|
}
|
||||||
public String getScoreS(){
|
/**
|
||||||
|
* @return Score as String
|
||||||
|
*/
|
||||||
|
public static String getScoreS(){
|
||||||
int score=getScore();
|
int score=getScore();
|
||||||
Integer string= new Integer(score);
|
Integer string= new Integer(score);
|
||||||
return string.toString();
|
return string.toString();
|
||||||
}
|
}
|
||||||
//resets score
|
/**
|
||||||
public void resetScore(){
|
* setzt die BonusZeit bis dahin es den Zeitbonus gibt
|
||||||
score=0;
|
* @param bonusTime
|
||||||
|
*/
|
||||||
|
public static void setBonusTime(int bonusTime){
|
||||||
|
Score.bonusTime=bonusTime;
|
||||||
}
|
}
|
||||||
//raises score
|
|
||||||
public void raiseScore(int additional){
|
/**
|
||||||
|
* erhöht den Score um:
|
||||||
|
* @param additional
|
||||||
|
*/
|
||||||
|
public static void raiseScore(int additional){
|
||||||
score+=additional;
|
score+=additional;
|
||||||
}
|
}
|
||||||
//reduces score; when score<0, score=0;
|
/**
|
||||||
public void reduceScore(int reduce){
|
* senkt den Score um:
|
||||||
|
* @param reduce
|
||||||
|
*/
|
||||||
|
public static void reduceScore(int reduce){
|
||||||
score-=reduce;
|
score-=reduce;
|
||||||
//when score less than 0
|
//when score less than 0
|
||||||
if (score<0){
|
if (score<0){
|
||||||
score=0;
|
score=0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* berechnet den endgültigen Score und gibt diesen zurück
|
||||||
|
* @return endScore
|
||||||
|
*/
|
||||||
|
public static int endScore(){
|
||||||
|
int manipulations=StatusPanelAdder.getManipulations();
|
||||||
|
int manipulationsBonus=600/manipulations;
|
||||||
|
int endScore=score + manipulationsBonus;
|
||||||
|
if (Timer.getAllInSeconds()<bonusTime){
|
||||||
|
endScore+=(bonusTime-Timer.getAllInSeconds());
|
||||||
|
}
|
||||||
|
|
||||||
|
return endScore;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,27 +1,42 @@
|
|||||||
package de.heatup.ui.statusPanel;
|
package de.heatup.ui.statusPanel;
|
||||||
|
|
||||||
import java.util.Date;
|
|
||||||
|
|
||||||
|
|
||||||
public class Timer {
|
public class Timer {
|
||||||
|
private static int minute;
|
||||||
|
private static int seconds;
|
||||||
|
private static int ticktick;
|
||||||
|
|
||||||
static double elapsedTime = 0L;
|
|
||||||
public static void main(String[] args){
|
public static void tickTimer(){
|
||||||
double startTime = System.currentTimeMillis();
|
ticktick++;
|
||||||
|
if (ticktick==60){
|
||||||
//1s = 1000ms
|
ticktick=0;
|
||||||
while (elapsedTime <10000) {
|
raiseSeconds();
|
||||||
|
|
||||||
elapsedTime = (new Date()).getTime() - startTime;
|
|
||||||
System.out.println(elapsedTime);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public double getTime(){
|
|
||||||
return elapsedTime;
|
|
||||||
}
|
}
|
||||||
|
private static void raiseSeconds(){
|
||||||
|
seconds++;
|
||||||
|
if (seconds==60){
|
||||||
|
minute++;
|
||||||
|
seconds=0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public static String getMinuteS(){
|
||||||
|
String formatted = String.format("%02d", minute);
|
||||||
|
return formatted;
|
||||||
|
}
|
||||||
|
public static String getSecondsS(){
|
||||||
|
String formatted = String.format("%02d", seconds);
|
||||||
|
return formatted;
|
||||||
|
}
|
||||||
|
public static int getMinute(){
|
||||||
|
return minute;
|
||||||
|
}
|
||||||
|
public static int getSeconds(){
|
||||||
|
return seconds;
|
||||||
|
}
|
||||||
|
public static int getAllInSeconds(){
|
||||||
|
int all=minute*60+seconds;
|
||||||
|
return all;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user