mirror of
https://github.com/jokerx3/HeatUp
synced 2026-07-27 10:19:46 +02:00
Gameloop hinzugefügt und Anpassungen am GameInterface
This commit is contained in:
@@ -12,9 +12,20 @@ public class ImageLoader {
|
||||
/*
|
||||
* TODO: Better solution like try catch if image not found
|
||||
*/
|
||||
/*
|
||||
* #: Path
|
||||
* -: Wall
|
||||
* 0 - 9: Hardware
|
||||
*/
|
||||
public static BufferedImage getBufferedImage(char key) {
|
||||
String imageFileName;
|
||||
switch (key) {
|
||||
case '#':
|
||||
imageFileName="src/de/heatup/resources/images/25x25_black.png";
|
||||
break;
|
||||
case '-':
|
||||
imageFileName="src/de/heatup/resources/images/25x25_red.png";
|
||||
break;
|
||||
case 'u':
|
||||
imageFileName="src/de/heatup/resources/images/little_green_guy_up.png";
|
||||
break;
|
||||
|
||||
@@ -25,11 +25,6 @@ public class StaticObject extends JComponent {
|
||||
private int staticObjectWidth;
|
||||
private int staticObjectHeight;
|
||||
|
||||
/*
|
||||
* #: Path
|
||||
* -: Wall
|
||||
* 0 - 9: Hardware
|
||||
*/
|
||||
public StaticObject(char staticObjectType, Point location, int staticObjectWidth, int staticObjectHeight) {
|
||||
this.staticObjectType = staticObjectType;
|
||||
this.location = location;
|
||||
@@ -50,7 +45,6 @@ public class StaticObject extends JComponent {
|
||||
if ( bf1 == null ) {
|
||||
loadBufferedImage();
|
||||
}
|
||||
System.out.println(this.bf1.getWidth() + " " + this.bf1.getHeight());
|
||||
//g2d.rotate(0.2, 10, 10);
|
||||
|
||||
if ( rescaleFactor != 0.0 ) {
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
package de.heatup.testing;
|
||||
|
||||
import de.heatup.mapengine.MapEngine;
|
||||
import de.heatup.objects.StaticObject;
|
||||
import de.heatup.ui.GameInterface;
|
||||
|
||||
public class GameLoop {
|
||||
|
||||
public static void startGameLoop() {
|
||||
|
||||
MapEngine me = new MapEngine(1);
|
||||
for (StaticObject currentStaticObject : me.getAllMapObjects()) {
|
||||
GameInterface.getGamePanel().add(currentStaticObject);
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -10,9 +10,11 @@ import javax.swing.BorderFactory;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JPanel;
|
||||
|
||||
import de.heatup.mapengine.MapEngine;
|
||||
import de.heatup.objects.DynamicObject;
|
||||
import de.heatup.objects.StaticObject;
|
||||
import de.heatup.objects.logic;
|
||||
import de.heatup.testing.GameLoop;
|
||||
|
||||
|
||||
public class GameInterface extends JFrame {
|
||||
@@ -21,13 +23,13 @@ public class GameInterface extends JFrame {
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 1L;
|
||||
private JPanel outerPanel;
|
||||
private JPanel statusPanel;
|
||||
private JPanel gamePanel;
|
||||
private JPanel actionPanel;
|
||||
private static JPanel outerPanel;
|
||||
private static JPanel statusPanel;
|
||||
private static JPanel gamePanel;
|
||||
private static JPanel actionPanel;
|
||||
//private BufferedImage image;
|
||||
|
||||
public void createGUI() {
|
||||
public static void createGUI() {
|
||||
final JFrame frame = new JFrame();
|
||||
|
||||
frame.setTitle("HeatUP!");
|
||||
@@ -79,39 +81,16 @@ public class GameInterface extends JFrame {
|
||||
EventQueue.invokeLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
GameInterface gameWindow = new GameInterface();
|
||||
gameWindow.createGUI();
|
||||
|
||||
/*
|
||||
* Test dynamic objects
|
||||
*/
|
||||
//DynamicObject opponent1 = new DynamicObject();
|
||||
//opponent1.setBounds(0, 0, opponent1.getWidth(), opponent1.getHeight());
|
||||
//gameWindow.gamePanel.add(opponent1);
|
||||
|
||||
//DynamicObject opponent2 = new DynamicObject();
|
||||
//opponent2.setBounds(0, 0, opponent2.getWidth(), opponent2.getWidth());
|
||||
//gameWindow.gamePanel.add(opponent2);
|
||||
|
||||
//logic.startMovement(opponent1);
|
||||
//logic.startMovement(opponent2);
|
||||
//opponent1.setRescale(0.4);
|
||||
|
||||
/*
|
||||
* Test static objects
|
||||
*/
|
||||
Point p1 = new Point(100, 100);
|
||||
StaticObject sObj1 = new StaticObject('d',p1);
|
||||
|
||||
gameWindow.gamePanel.add(sObj1);
|
||||
|
||||
|
||||
//GameInterface gameWindow = new GameInterface();
|
||||
GameInterface.createGUI();
|
||||
|
||||
// TODO: Gameloop needs to be added here!!!
|
||||
GameLoop.startGameLoop();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public JPanel getGamePanel() {
|
||||
return this.gamePanel;
|
||||
public static JPanel getGamePanel() {
|
||||
return gamePanel;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user