diff --git a/HeatUp/src/de/heatup/objects/ImageLoader.java b/HeatUp/src/de/heatup/objects/ImageLoader.java index b63576d..730b13d 100644 --- a/HeatUp/src/de/heatup/objects/ImageLoader.java +++ b/HeatUp/src/de/heatup/objects/ImageLoader.java @@ -27,16 +27,16 @@ public class ImageLoader { imageFileName="src/de/heatup/resources/images/25x25_wall_orange_2.png"; break; case 'u': - imageFileName="src/de/heatup/resources/images/little_green_guy_up.png"; + imageFileName="src/de/heatup/resources/images/little_green_guy_verysmall.png"; break; case 'd': - imageFileName="src/de/heatup/resources/images/little_green_guy.png"; + imageFileName="src/de/heatup/resources/images/little_green_guy_verysmall.png"; break; case 'l': - imageFileName="src/de/heatup/resources/images/little_green_guy_left.png"; + imageFileName="src/de/heatup/resources/images/little_green_guy_verysmall.png"; break; case 'r': - imageFileName="src/de/heatup/resources/images/little_green_guy_right.png"; + imageFileName="src/de/heatup/resources/images/little_green_guy_verysmall.png"; break; default: imageFileName="src/de/heatup/resources/images/dummy_image.png"; diff --git a/HeatUp/src/de/heatup/objects/StaticObject.java b/HeatUp/src/de/heatup/objects/StaticObject.java index ebf1066..496f76c 100644 --- a/HeatUp/src/de/heatup/objects/StaticObject.java +++ b/HeatUp/src/de/heatup/objects/StaticObject.java @@ -10,6 +10,8 @@ import java.io.IOException; import javax.imageio.ImageIO; import javax.swing.JComponent; +import de.heatup.cfg.Config; + /* * Draft for static objects */ @@ -30,18 +32,21 @@ public class StaticObject extends JComponent { private int staticObjectHeight; public StaticObject(char staticObjectType, Point location, int staticObjectWidth, int staticObjectHeight) { +// System.out.println("Object Type: " + staticObjectType + "\t" +staticObjectHeight + " h:w " + staticObjectWidth); this.staticObjectType = staticObjectType; this.location = location; this.staticObjectWidth = staticObjectWidth; this.staticObjectHeight = staticObjectHeight; loadBufferedImage(); setAutoBounds(location.x, location.y); +// autoRescale(); +// System.out.println(getDebugInfo()); } public StaticObject(char staticObjectType, Point location) { - this(staticObjectType, location, 25, 25); + this(staticObjectType, location, Config.singleTilePixels, Config.singleTilePixels); } - + public void paintComponent(Graphics g) { this.g2d = (Graphics2D)g; @@ -51,9 +56,11 @@ public class StaticObject extends JComponent { } //g2d.rotate(0.2, 10, 10); - if ( doRescale ) { - g2d.scale(rescaleFactorX, rescaleFactorY); - } + // TODO: Check if we can store a rescaled image in bf1??? +// if ( doRescale ) { +// System.out.println("Hit: " + rescaleFactorX + " " + rescaleFactorY); +// g2d.scale(rescaleFactorX, rescaleFactorY); +// } g2d.drawImage(bf1, 0, 0, this); g2d.finalize(); @@ -67,24 +74,30 @@ public class StaticObject extends JComponent { this.bf1 = image; } - public void setRescale(double rescaleFactorX, double rescaleFactorY) { - this.rescaleFactorX = rescaleFactorX; - this.rescaleFactorY = rescaleFactorY; - this.doRescale = true; + private void autoRescale() { + // TODO: get original width and hight of bf1 + // Calculate factor new/original + // Rescale image using factor + // Save new bf in bf1 ??? + this.rescaleFactorX = (double)this.staticObjectWidth / (double)this.bf1.getWidth(); + this.rescaleFactorY = (double)this.staticObjectHeight / (double)this.bf1.getHeight(); + + //System.out.println("Object: " + this.staticObjectType + "\tBuffered Image: Height: " + this.bf1.getHeight() + "\t Width: " + this.bf1.getWidth() + "\tStatic Object: Height: " + this.staticObjectHeight + "\t Width: " + this.staticObjectWidth); + + if (this.rescaleFactorX != 1 || this.rescaleFactorY != 1 ) { + this.doRescale = true; + } + } - public void unsetRescale() { - this.rescaleFactorX = 0.0; - this.rescaleFactorY = 0.0; - this.doRescale = false; - } + // TODO: getter für höhe breite position public void setAutoBounds(int x, int y) { this.setBounds(x, y, this.bf1.getWidth(), this.bf1.getHeight()); } public String getDebugInfo() { - String info = "Debug: " + "Rescale enabled:" + this.doRescale + "Rescale X:" + this.rescaleFactorX + "Rescale Y:" + this.rescaleFactorY + " Heigth:" + this.staticObjectHeight + " Width:" + this.staticObjectWidth + " StaticObjectType:" + this.staticObjectType + " X Position:" + this.location.x + " Y Position:" + this.location.y; + String info = "Debug: " + "Rescale? " + this.doRescale + "\tScale X:" + this.rescaleFactorX + "\tScale Y: " + this.rescaleFactorY + "\tsH: " + this.staticObjectHeight + "\tsW: " + this.staticObjectWidth + "\tStaticObjectType: " + this.staticObjectType + "\tbW : " + this.bf1.getWidth() + "\tbH :" + this.bf1.getHeight(); return info; } } diff --git a/HeatUp/src/de/heatup/objects/logic.java b/HeatUp/src/de/heatup/objects/logic.java index 66921cf..a9e2a04 100644 --- a/HeatUp/src/de/heatup/objects/logic.java +++ b/HeatUp/src/de/heatup/objects/logic.java @@ -84,7 +84,7 @@ public class logic { //System.out.println("x: " + dynObj.getX() + " y: " + dynObj.getY()); //System.out.println("h: " + dynObj.getHeight() + " w: " + dynObj.getWidth()); try { - Thread.sleep(10); + Thread.sleep(40); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); diff --git a/HeatUp/src/de/heatup/resources/images/little_green_guy_verysmall.png b/HeatUp/src/de/heatup/resources/images/little_green_guy_verysmall.png new file mode 100644 index 0000000..fe6e986 Binary files /dev/null and b/HeatUp/src/de/heatup/resources/images/little_green_guy_verysmall.png differ diff --git a/HeatUp/src/de/heatup/testing/GameLoop.java b/HeatUp/src/de/heatup/testing/GameLoop.java index be6d589..c7d1ac9 100644 --- a/HeatUp/src/de/heatup/testing/GameLoop.java +++ b/HeatUp/src/de/heatup/testing/GameLoop.java @@ -2,6 +2,7 @@ package de.heatup.testing; import javax.swing.JLabel; +import de.heatup.cfg.Config; import de.heatup.mapengine.MapEngine; import de.heatup.objects.DynamicObject; import de.heatup.objects.StaticObject; @@ -25,7 +26,7 @@ public class GameLoop { //dynO3.setRescale(1.5,3.5); - +// Config.setGamePanelWidth(900); MapEngine me = new MapEngine(1); for (StaticObject currentStaticObject : me.getAllMapObjects()) { GameInterface.getGamePanel().add(currentStaticObject); diff --git a/HeatUp/src/de/heatup/ui/GameInterface.java b/HeatUp/src/de/heatup/ui/GameInterface.java index 955de4c..847a71f 100644 --- a/HeatUp/src/de/heatup/ui/GameInterface.java +++ b/HeatUp/src/de/heatup/ui/GameInterface.java @@ -51,11 +51,11 @@ public class GameInterface extends JFrame { final JFrame frame = new JFrame(); // Fullscreen testing: Remember not to use pack() when using fullscreen mode - frame.setUndecorated(true); - frame.setResizable(false); - frame.setExtendedState(Frame.MAXIMIZED_BOTH); - frame.validate(); - GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().setFullScreenWindow(frame); +// frame.setUndecorated(true); +// frame.setResizable(false); +// frame.setExtendedState(Frame.MAXIMIZED_BOTH); +// frame.validate(); +// GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().setFullScreenWindow(frame); frame.setTitle("HeatUP!"); frame.setDefaultCloseOperation(EXIT_ON_CLOSE); @@ -94,7 +94,7 @@ public class GameInterface extends JFrame { frame.add(outerPanel); // Comment out for fullscreen - //frame.pack(); + frame.pack(); frame.setVisible(true); frame.repaint(); } diff --git a/HeatUp/src/de/heatup/ui/StatusPanelAdder.java b/HeatUp/src/de/heatup/ui/StatusPanelAdder.java new file mode 100644 index 0000000..245efce --- /dev/null +++ b/HeatUp/src/de/heatup/ui/StatusPanelAdder.java @@ -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(); + } +} + diff --git a/HeatUp/src/de/heatup/ui/statusPanel/Score.java b/HeatUp/src/de/heatup/ui/statusPanel/Score.java new file mode 100644 index 0000000..d43b472 --- /dev/null +++ b/HeatUp/src/de/heatup/ui/statusPanel/Score.java @@ -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; + } + } + +} diff --git a/HeatUp/src/de/heatup/ui/statusPanel/Temperature.java b/HeatUp/src/de/heatup/ui/statusPanel/Temperature.java new file mode 100644 index 0000000..b8d5078 --- /dev/null +++ b/HeatUp/src/de/heatup/ui/statusPanel/Temperature.java @@ -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