mirror of
https://github.com/jokerx3/HeatUp
synced 2026-07-27 10:09:44 +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{
|
||||
private Score score;
|
||||
private Timer timer;
|
||||
private static JPanel panel;
|
||||
private static int hgap=30;
|
||||
private static int vgap=9;
|
||||
private static int modifier=-1;
|
||||
private static int temping=0;
|
||||
private static int manipulations=0;
|
||||
private static double tempPlus=0.0;
|
||||
private static double tempMinus=0.0;
|
||||
private static int temping=0;
|
||||
private static double barSpeed=0.01;
|
||||
private static boolean ende=false;
|
||||
private static JLabel labelTempC= new JLabel("§");
|
||||
@@ -37,7 +36,7 @@ public class StatusPanelAdder{
|
||||
private static JLabel labelPowerUp = new JLabel("PowerUp");
|
||||
private static JLabel powerUpLabel = new JLabel(/*new ImageIcon("path_to_image.png")*/"powerUpLabel");
|
||||
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 emulogictext;
|
||||
private static Font ttfBase;
|
||||
@@ -73,20 +72,32 @@ public class StatusPanelAdder{
|
||||
|
||||
}
|
||||
public int getScore(){
|
||||
return score.getScore();
|
||||
}
|
||||
public double getTime(){
|
||||
return timer.getTime();
|
||||
return Score.getScore();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param newPanel das zu verwendende Panel zur Bearbeitung
|
||||
*/
|
||||
public static void setPanel(JPanel newPanel){
|
||||
newPanel.setLayout(new FlowLayout(FlowLayout.CENTER, hgap,5));
|
||||
panel=newPanel;
|
||||
}
|
||||
|
||||
public static void addManipulations(){
|
||||
manipulations+=1;
|
||||
Score.raiseScore(25);
|
||||
}
|
||||
public static int getManipulations(){
|
||||
return manipulations;
|
||||
}
|
||||
|
||||
|
||||
public static void tick() {
|
||||
Timer.tickTimer();
|
||||
timeLabel.setText(Timer.getMinuteS() + ":" + Timer.getSecondsS());
|
||||
|
||||
/**
|
||||
* Temperaturbearbeitung
|
||||
*/
|
||||
labelTempC.setText(tempBar.getValue() + "°C");
|
||||
temping=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(){
|
||||
implementFont();
|
||||
emulogicheading = ttfBase.deriveFont(Font.PLAIN, 16);
|
||||
|
||||
@@ -1,35 +1,66 @@
|
||||
package de.heatup.ui.statusPanel;
|
||||
|
||||
import de.heatup.ui.StatusPanelAdder;
|
||||
|
||||
|
||||
public class Score {
|
||||
private int score;
|
||||
public Score(){
|
||||
score=0;
|
||||
}
|
||||
//returns score
|
||||
public int getScore(){
|
||||
private static int score;
|
||||
private static int bonusTime=180;
|
||||
/**
|
||||
* @return Score
|
||||
*/
|
||||
public static int getScore(){
|
||||
return score;
|
||||
}
|
||||
public String getScoreS(){
|
||||
/**
|
||||
* @return Score as String
|
||||
*/
|
||||
public static String getScoreS(){
|
||||
int score=getScore();
|
||||
Integer string= new Integer(score);
|
||||
return string.toString();
|
||||
}
|
||||
//resets score
|
||||
public void resetScore(){
|
||||
score=0;
|
||||
/**
|
||||
* setzt die BonusZeit bis dahin es den Zeitbonus gibt
|
||||
* @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;
|
||||
}
|
||||
//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;
|
||||
//when score less than 0
|
||||
if (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;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
|
||||
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){
|
||||
double startTime = System.currentTimeMillis();
|
||||
|
||||
//1s = 1000ms
|
||||
while (elapsedTime <10000) {
|
||||
|
||||
elapsedTime = (new Date()).getTime() - startTime;
|
||||
System.out.println(elapsedTime);
|
||||
public static void tickTimer(){
|
||||
ticktick++;
|
||||
if (ticktick==60){
|
||||
ticktick=0;
|
||||
raiseSeconds();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
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