From caeec9dccef2f8ec99726100122e7ff3093c895d Mon Sep 17 00:00:00 2001 From: feschi55 Date: Fri, 21 Nov 2014 14:39:39 +0100 Subject: [PATCH] =?UTF-8?q?TempBar=20Ver=C3=A4nderung=20implementiert?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- HeatUp/src/de/heatup/ui/StatusPanelAdder.java | 88 +++++++++++++------ 1 file changed, 63 insertions(+), 25 deletions(-) diff --git a/HeatUp/src/de/heatup/ui/StatusPanelAdder.java b/HeatUp/src/de/heatup/ui/StatusPanelAdder.java index 54df9ec..02b6114 100644 --- a/HeatUp/src/de/heatup/ui/StatusPanelAdder.java +++ b/HeatUp/src/de/heatup/ui/StatusPanelAdder.java @@ -13,18 +13,41 @@ import de.heatup.ui.statusPanel.Timer; public class StatusPanelAdder{ - private Temperature temp; private Score score; private Timer timer; private static JPanel panel; - private static JLabel labelTemp= new JLabel("temperature"); - private static JProgressBar tempBar; private static int hgap=30; private static int vgap=9; - private static boolean updown = true; + private static int modifier=-1; + private static double tempPlus=0.0; + private static double tempMinus=0.0; + private static int temping=0; + private static double barSpeed=0.01; - public int getTemp(){ - return temp.getTemp(); + private static JLabel labelTemp= new JLabel("temperature"); + private static JProgressBar tempBar; + private static JLabel labelScore= new JLabel("score"); + private static JLabel scoreLabel= new JLabel("new Score Label"); + 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"); + + public static void raiseMod(){ + if (modifier==-1){ + modifier=1; + } else { + modifier+=1; + } + } + public static void reduceMod(){ + if (modifier==1){ + modifier=-1; + } else if(modifier==-1){ + } else { + modifier-=1; + } + } public int getScore(){ return score.getScore(); @@ -38,29 +61,45 @@ public class StatusPanelAdder{ panel=newPanel; } + + public static void tick() { - int mod; - if (tempBar.getValue()==90) { - updown = false; + temping=0; + if (modifier<0){ + barSpeed=0.015; + tempMinus+=barSpeed*modifier; + if (tempMinus<-1){ + temping=-1; + tempMinus+=1; + } + } else if (modifier>0){ + barSpeed=0.02; + tempPlus+=barSpeed*modifier; + if (tempPlus>1){ + temping=1; + tempPlus=-1; + } } - if (tempBar.getValue()==30) { - updown = true; - } - if (updown) { - mod = 1; + + + if (tempBar.getValue()<=30 && modifier==-1) { } else { - mod = -1; + tempBar.setValue(tempBar.getValue()+temping); } - tempBar.setValue((tempBar.getValue()+mod)); - - + System.out.println(tempBar.getValue() + " " + modifier); } + + + + + + public static void createPanel(){ labelTemp.setFont(new Font("emulogic", Font.CENTER_BASELINE, 16)); labelTemp.setForeground(Color.YELLOW); - tempBar= new JProgressBar(30,90); + tempBar= new JProgressBar(30,200); tempBar.setValue(45); JPanel tempPanel=new JPanel(); @@ -70,10 +109,10 @@ public class StatusPanelAdder{ tempPanel.setBackground(Color.BLACK); - JLabel labelScore= new JLabel("score"); + labelScore.setFont(new Font("emulogic", Font.CENTER_BASELINE, 16)); labelScore.setForeground(Color.YELLOW); - JLabel scoreLabel= new JLabel("new Score Label"); + scoreLabel.setFont(new Font("emulogic", Font.CENTER_BASELINE, 12)); scoreLabel.setForeground(Color.YELLOW); JPanel scorePanel=new JPanel(); @@ -82,10 +121,10 @@ public class StatusPanelAdder{ scorePanel.add(scoreLabel, BorderLayout.SOUTH); scorePanel.setBackground(Color.BLACK); - JLabel labelPowerUp = new JLabel("PowerUp"); + labelPowerUp.setFont(new Font("emulogic", Font.CENTER_BASELINE, 16)); labelPowerUp.setForeground(Color.YELLOW); - JLabel powerUpLabel = new JLabel(/*new ImageIcon("path_to_image.png")*/"powerUpLabel"); + powerUpLabel.setFont(new Font("emulogic", Font.CENTER_BASELINE, 12)); powerUpLabel.setForeground(Color.YELLOW); @@ -96,11 +135,10 @@ public class StatusPanelAdder{ powerUpPanel.setBackground(Color.BLACK); - JLabel labelTime=new JLabel("Time"); + labelTime.setFont(new Font("emulogic", Font.CENTER_BASELINE, 16)); labelTime.setSize(100,10); labelTime.setForeground(Color.YELLOW); - JLabel timeLabel = new JLabel("123456789"); timeLabel.setFont(new Font("emulogic", Font.CENTER_BASELINE, 12)); timeLabel.setForeground(Color.YELLOW); JPanel timePanel=new JPanel();