diff --git a/HeatUp/src/de/heatup/objects/DynamicObject.java b/HeatUp/src/de/heatup/objects/DynamicObject.java index 45c81d1..d3bb555 100644 --- a/HeatUp/src/de/heatup/objects/DynamicObject.java +++ b/HeatUp/src/de/heatup/objects/DynamicObject.java @@ -16,10 +16,13 @@ import javax.swing.JComponent; */ public class DynamicObject extends JComponent{ private static final long serialVersionUID = 1L; - //private Image image; + //private Image image; private BufferedImage bf1; private Graphics2D g2d; - private double rescaleFactor = 0.0; + + private boolean doRescale = false; + private double rescaleFactorX = 0.0; + private double rescaleFactorY = 0.0; public DynamicObject() { } @@ -32,8 +35,8 @@ public class DynamicObject extends JComponent{ } //g2d.rotate(0.3, 10, 10); - if ( rescaleFactor != 0.0 ) { - g2d.scale(rescaleFactor, rescaleFactor); + if ( doRescale ) { + g2d.scale(rescaleFactorX, rescaleFactorY); } g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_ON); @@ -54,9 +57,21 @@ public class DynamicObject extends JComponent{ this.bf1 = image; } - public void setRescale(double rescaleFactor) { - this.rescaleFactor = rescaleFactor; - //this.setBounds(x, y, width, height); + public void setRescale(double rescaleFactorX, double rescaleFactorY) { + this.rescaleFactorX = rescaleFactorX; + this.rescaleFactorY = rescaleFactorY; + this.doRescale = true; } + public void unsetRescale() { + this.rescaleFactorX = 0.0; + this.rescaleFactorY = 0.0; + this.doRescale = false; + } + + public void setAutoBounds(int x, int y) { + this.setBounds(x, y, this.bf1.getWidth(), this.bf1.getHeight()); + } + + } diff --git a/HeatUp/src/de/heatup/objects/ImageLoader.java b/HeatUp/src/de/heatup/objects/ImageLoader.java index ef433ed..b63576d 100644 --- a/HeatUp/src/de/heatup/objects/ImageLoader.java +++ b/HeatUp/src/de/heatup/objects/ImageLoader.java @@ -24,7 +24,7 @@ public class ImageLoader { imageFileName="src/de/heatup/resources/images/25x25_black.png"; break; case '-': - imageFileName="src/de/heatup/resources/images/25x25_red.png"; + 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"; @@ -48,7 +48,12 @@ public class ImageLoader { loadedBufferedImage = ImageIO.read(new File(imageFileName)); } catch (Exception e) { // TODO: handle exception - } + } + + // loadedBufferedImage shouldn't be null here anymore, if so an error occurred + if (loadedBufferedImage == null) { + System.out.println("No texture defined, failed to use default texture."); + } return loadedBufferedImage; } diff --git a/HeatUp/src/de/heatup/objects/StaticObject.java b/HeatUp/src/de/heatup/objects/StaticObject.java index 09c9f7c..ebf1066 100644 --- a/HeatUp/src/de/heatup/objects/StaticObject.java +++ b/HeatUp/src/de/heatup/objects/StaticObject.java @@ -19,7 +19,11 @@ public class StaticObject extends JComponent { //private Image image; private BufferedImage bf1; private Graphics2D g2d; - private double rescaleFactor = 0.0; + + private boolean doRescale = false; + private double rescaleFactorX = 0.0; + private double rescaleFactorY = 0.0; + private Point location; private char staticObjectType; private int staticObjectWidth; @@ -47,9 +51,10 @@ public class StaticObject extends JComponent { } //g2d.rotate(0.2, 10, 10); - if ( rescaleFactor != 0.0 ) { - g2d.scale(rescaleFactor, rescaleFactor); + if ( doRescale ) { + g2d.scale(rescaleFactorX, rescaleFactorY); } + g2d.drawImage(bf1, 0, 0, this); g2d.finalize(); } @@ -62,9 +67,16 @@ public class StaticObject extends JComponent { this.bf1 = image; } - public void setRescale(double rescaleFactor) { - this.rescaleFactor = rescaleFactor; - //this.setBounds(x, y, width, height); + public void setRescale(double rescaleFactorX, double rescaleFactorY) { + this.rescaleFactorX = rescaleFactorX; + this.rescaleFactorY = rescaleFactorY; + this.doRescale = true; + } + + public void unsetRescale() { + this.rescaleFactorX = 0.0; + this.rescaleFactorY = 0.0; + this.doRescale = false; } public void setAutoBounds(int x, int y) { @@ -72,7 +84,7 @@ public class StaticObject extends JComponent { } public String getDebugInfo() { - String info = "Debug: " + "Rescale Factor:" + this.rescaleFactor + " Heigth:" + this.staticObjectHeight + " Width:" + this.staticObjectWidth + " StaticObjectType:" + this.staticObjectType + " X Position:" + this.location.x + " Y Position:" + this.location.y; + 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; return info; } } diff --git a/HeatUp/src/de/heatup/resources/images/25x25_theGrid.png b/HeatUp/src/de/heatup/resources/images/25x25_theGrid.png new file mode 100644 index 0000000..5fc705a Binary files /dev/null and b/HeatUp/src/de/heatup/resources/images/25x25_theGrid.png differ diff --git a/HeatUp/src/de/heatup/resources/images/25x25_wall_orange.png b/HeatUp/src/de/heatup/resources/images/25x25_wall_orange.png new file mode 100644 index 0000000..7615d05 Binary files /dev/null and b/HeatUp/src/de/heatup/resources/images/25x25_wall_orange.png differ diff --git a/HeatUp/src/de/heatup/resources/images/25x25_wall_orange_1.png b/HeatUp/src/de/heatup/resources/images/25x25_wall_orange_1.png new file mode 100644 index 0000000..ed5763c Binary files /dev/null and b/HeatUp/src/de/heatup/resources/images/25x25_wall_orange_1.png differ diff --git a/HeatUp/src/de/heatup/resources/images/25x25_wall_orange_2.png b/HeatUp/src/de/heatup/resources/images/25x25_wall_orange_2.png new file mode 100644 index 0000000..074a6e5 Binary files /dev/null and b/HeatUp/src/de/heatup/resources/images/25x25_wall_orange_2.png differ diff --git a/HeatUp/src/de/heatup/resources/maps/map1.txt b/HeatUp/src/de/heatup/resources/maps/map1.txt index 688914d..3c648a4 100644 --- a/HeatUp/src/de/heatup/resources/maps/map1.txt +++ b/HeatUp/src/de/heatup/resources/maps/map1.txt @@ -1,6 +1,6 @@ ################################ -#--11-----#-----------#222222--# -#--11-----#-----------#222222--# +#--1111----#----------#222222--# +#--1111----#----------#222222--# #######################222222### #---------#----------#########-# ###############-######---------# diff --git a/HeatUp/src/de/heatup/testing/GameLoop.java b/HeatUp/src/de/heatup/testing/GameLoop.java index dde61f1..be6d589 100644 --- a/HeatUp/src/de/heatup/testing/GameLoop.java +++ b/HeatUp/src/de/heatup/testing/GameLoop.java @@ -1,5 +1,7 @@ package de.heatup.testing; +import javax.swing.JLabel; + import de.heatup.mapengine.MapEngine; import de.heatup.objects.DynamicObject; import de.heatup.objects.StaticObject; @@ -21,13 +23,16 @@ public class GameLoop { DynamicObject dynO4 = new DynamicObject(); GameInterface.getGamePanel().add(dynO4); - dynO4.setRescale(0.5); + //dynO3.setRescale(1.5,3.5); + MapEngine me = new MapEngine(1); for (StaticObject currentStaticObject : me.getAllMapObjects()) { GameInterface.getGamePanel().add(currentStaticObject); } + GameInterface.getGamePanel().setVisible(true); + //GameInterface.getGamePanel().repaint(); //GameInterface.getGamePanel().setComponentZOrder(dynO1, 1); //GameInterface.getGamePanel().add(dynO1); diff --git a/HeatUp/src/de/heatup/ui/GameInterface.java b/HeatUp/src/de/heatup/ui/GameInterface.java index 3be2d03..1f2d99b 100644 --- a/HeatUp/src/de/heatup/ui/GameInterface.java +++ b/HeatUp/src/de/heatup/ui/GameInterface.java @@ -14,6 +14,7 @@ import java.io.IOException; import javax.swing.BorderFactory; import javax.swing.JFrame; +import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.UIManager; import javax.swing.UnsupportedLookAndFeelException; @@ -49,12 +50,12 @@ public class GameInterface extends JFrame { final JFrame frame = new JFrame(); -// Fullscreen testing -// frame.setUndecorated(true); -// frame.setResizable(false); -// frame.setExtendedState(Frame.MAXIMIZED_BOTH); -// frame.validate(); -// GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().setFullScreenWindow(frame); +// 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.setTitle("HeatUP!"); frame.setDefaultCloseOperation(EXIT_ON_CLOSE); @@ -78,8 +79,9 @@ public class GameInterface extends JFrame { gamePanel = new JPanel(); gamePanel.setLayout(null); gamePanel.setPreferredSize(new Dimension(800,600)); + gamePanel.setVisible(true); //gamePanel.setBorder(BorderFactory.createTitledBorder("gamePanel")); - + actionPanel = new JPanel(); actionPanel.setLayout(new GridLayout(1,1)); //actionPanel.setBorder(BorderFactory.createTitledBorder("actionPanel")); @@ -91,7 +93,8 @@ public class GameInterface extends JFrame { outerPanel.add(actionPanel,BorderLayout.SOUTH); frame.add(outerPanel); - frame.pack(); + // Comment out for fullscreen + //frame.pack(); frame.setVisible(true); frame.repaint(); } @@ -106,10 +109,11 @@ public class GameInterface extends JFrame { EventQueue.invokeLater(new Runnable() { @Override public void run() { - //GameInterface gameWindow = new GameInterface(); + // GameInterface is static now. + //GameInterface gameWindow = new GameInterface(); GameInterface.createGUI(); - - // TODO: Gameloop needs to be added here!!! + + // Start game loop to add player, opponents, maps and everything you need GameLoop.startGameLoop(); } });