mirror of
https://github.com/jokerx3/HeatUp
synced 2026-07-27 09:59:45 +02:00
Merge branch 'master' of github.com:jokerx3/prp
Conflicts:
This commit is contained in:
@@ -4,9 +4,9 @@ import java.awt.Point;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import de.heatup.logging.Logger;
|
||||
import de.heatup.objects.Opponent;
|
||||
import de.heatup.objects.Player;
|
||||
import de.heatup.objects.PowerUp;
|
||||
import de.heatup.testing.Opponent;
|
||||
import de.heatup.testing.Player;
|
||||
|
||||
public class CollisionHandler {
|
||||
private static ArrayList<Player> movingObjects = new ArrayList<Player>();
|
||||
|
||||
@@ -1,77 +0,0 @@
|
||||
package de.heatup.objects;
|
||||
|
||||
import java.awt.BasicStroke;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.RenderingHints;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
import javax.swing.JComponent;
|
||||
|
||||
/*
|
||||
* Draft for dynamic objects
|
||||
*/
|
||||
public class DynamicObject extends JComponent{
|
||||
private static final long serialVersionUID = 1L;
|
||||
//private Image image;
|
||||
private BufferedImage bf1;
|
||||
private Graphics2D g2d;
|
||||
|
||||
private boolean doRescale = false;
|
||||
private double rescaleFactorX = 0.0;
|
||||
private double rescaleFactorY = 0.0;
|
||||
|
||||
public DynamicObject() {
|
||||
}
|
||||
|
||||
public void paintComponent(Graphics g) {
|
||||
g2d = (Graphics2D)g;
|
||||
//this.image = Toolkit.getDefaultToolkit().getImage("src/de/heatup/resources/images/little_green_guy.png");
|
||||
if ( bf1 == null ) {
|
||||
loadBufferedImage();
|
||||
}
|
||||
|
||||
//g2d.rotate(0.3, 10, 10);
|
||||
if ( doRescale ) {
|
||||
g2d.scale(rescaleFactorX, rescaleFactorY);
|
||||
}
|
||||
|
||||
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_ON);
|
||||
g2d.drawImage(bf1, 0, 0, this);
|
||||
g2d.setStroke(new BasicStroke(8.0f));
|
||||
g2d.finalize();
|
||||
}
|
||||
|
||||
private void loadBufferedImage() {
|
||||
try {
|
||||
this.bf1 = ImageIO.read(new File("src/de/heatup/resources/images/little_green_guy.png"));
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void setImage(BufferedImage image) {
|
||||
this.bf1 = image;
|
||||
}
|
||||
|
||||
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());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,127 +0,0 @@
|
||||
package de.heatup.objects;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.Random;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
import javax.swing.ImageIcon;
|
||||
import javax.swing.JLabel;
|
||||
|
||||
public class Gegner {
|
||||
|
||||
private static int numberOfInstances;
|
||||
private BufferedImage opponentImage;
|
||||
private JLabel opponentLabel;
|
||||
public Thread t;
|
||||
public Gegner() throws IOException {
|
||||
numberOfInstances++;
|
||||
String fname;
|
||||
if (numberOfInstances == 1 ) {
|
||||
fname="../resources/images/25x25_black.png";
|
||||
} else if (numberOfInstances == 2) {
|
||||
fname="../resources/images/25x25_black.png";
|
||||
} else {
|
||||
fname="../resources/images/25x25_black.png";
|
||||
}
|
||||
opponentImage = ImageIO.read(new File("src/de/heatup/resources/images/25x25_black.png"));
|
||||
opponentLabel = new JLabel(new ImageIcon(opponentImage));
|
||||
this.gegnerLogik();
|
||||
}
|
||||
|
||||
public JLabel getLabel() {
|
||||
return this.opponentLabel;
|
||||
}
|
||||
|
||||
public int getX() {
|
||||
return this.opponentLabel.getLocation().x;
|
||||
}
|
||||
|
||||
public int getY() {
|
||||
return this.opponentLabel.getLocation().y;
|
||||
}
|
||||
|
||||
private void setY(int y) {
|
||||
this.opponentLabel.setLocation(this.opponentLabel.getLocation().x,y);
|
||||
}
|
||||
|
||||
private void setX(int x) {
|
||||
this.opponentLabel.setLocation(x,this.opponentLabel.getLocation().y);
|
||||
}
|
||||
|
||||
/*
|
||||
* Quick and dirty for testing...
|
||||
*/
|
||||
private void gegnerLogik() {
|
||||
final Random rand = new Random();
|
||||
t = new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
int movex=0, movey=0;
|
||||
int move = 0;
|
||||
int dir;
|
||||
while (true) {
|
||||
if ( move == 0 ) {
|
||||
dir = rand.nextInt(20)+1;
|
||||
// System.out.println("Entscheidung: " + dir);
|
||||
if ( dir < 5 || dir > 15) {
|
||||
movex = rand.nextInt(800)+1;
|
||||
move = 2;
|
||||
if (movex > 100) { move = -2; }
|
||||
movey = 0;
|
||||
// System.out.println("X " + move + " " + movex);
|
||||
|
||||
} else {
|
||||
movey = rand.nextInt(600)+1;
|
||||
move = 1;
|
||||
if (movey > 100) { move = -1; }
|
||||
movex = 0;
|
||||
// System.out.println("X " + move + " " + movex);
|
||||
}
|
||||
}
|
||||
|
||||
if ( getLabel().getX() <= 0 && move == -2 ) {
|
||||
move = move * -1;
|
||||
}
|
||||
if ( getLabel().getX() >= 752 && move == 2 ) {
|
||||
move = move * -1;
|
||||
}
|
||||
if ( getLabel().getY() <= 0 && move == -1 ) {
|
||||
move = move * -1;
|
||||
}
|
||||
if ( getLabel().getY() >= 552 && move == 1 ) {
|
||||
move = move * -1;
|
||||
}
|
||||
|
||||
// System.out.println("Move " + move + " Movex " + movex + " Movey " + movey);
|
||||
|
||||
if ( move == -2 && movex >= 0) {
|
||||
movex -= 4;
|
||||
getLabel().setBounds(getLabel().getX()-8, getLabel().getY(), 48, 48);
|
||||
} else if ( move == 2 && movex >= 0) {
|
||||
movex -= 4;
|
||||
getLabel().setBounds(getLabel().getX()+8, getLabel().getY(), 48, 48);
|
||||
} else if (move == -1 && movey >= 0) {
|
||||
movey -= 4;
|
||||
getLabel().setBounds(getLabel().getX(), getLabel().getY()-8, 48, 48);
|
||||
} else if (move == 1 && movey >= 0) {
|
||||
movey -= 4;
|
||||
getLabel().setBounds(getLabel().getX(), getLabel().getY()+8, 48, 48);
|
||||
} else {
|
||||
move = 0;
|
||||
}
|
||||
|
||||
// System.out.println("x: " + getX() + " y:" + getY());
|
||||
try {
|
||||
Thread.sleep(10);
|
||||
} catch (InterruptedException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
t.start();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -2,8 +2,6 @@ package de.heatup.objects;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import de.heatup.testing.Player;
|
||||
|
||||
public class InstancedObjects {
|
||||
private static ArrayList<Player> objects;
|
||||
|
||||
|
||||
@@ -1,108 +0,0 @@
|
||||
package de.heatup.objects;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.Point;
|
||||
import java.awt.RenderingHints;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Array;
|
||||
import java.util.Arrays;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
import javax.swing.ImageIcon;
|
||||
import javax.swing.JLabel;
|
||||
|
||||
|
||||
public class Objekt {
|
||||
/*
|
||||
* Deprecated
|
||||
*/
|
||||
|
||||
// private static int numberOfInstances;
|
||||
// private BufferedImage objectImage;
|
||||
// private JLabel objectLabel;
|
||||
// private Point objectArea;
|
||||
// private Point actionArea;
|
||||
// public Thread t;
|
||||
// private char objectIdentifier; // TODO: Identifizierung für Map Engine
|
||||
//
|
||||
// public Objekt(char objectIdentifier) throws IOException {
|
||||
// numberOfInstances++;
|
||||
// setObjectIdentifier(objectIdentifier);
|
||||
// setObjectImage();
|
||||
//
|
||||
// }
|
||||
//
|
||||
// private void setObjectImage() throws IOException {
|
||||
// String filename = getImageFilename(objectIdentifier);
|
||||
// System.out.println("Filename: " + filename);
|
||||
// //objectImage = ImageIO.read(new File(filename));
|
||||
// //objectLabel = new JLabel(new ImageIcon(objectImage));
|
||||
//
|
||||
// objectImage = ImageLoader.getBufferedImage(filename);
|
||||
// objectLabel = new JLabel(new ImageIcon(objectImage));
|
||||
// }
|
||||
//
|
||||
// /*
|
||||
// * Load corresponding image
|
||||
// */
|
||||
// private String getImageFilename(char objectIdentifier) {
|
||||
// String objectFilename;
|
||||
// switch (objectIdentifier) {
|
||||
// case '#':
|
||||
// // Path
|
||||
// objectFilename="src/de/heatup/resources/images/25x25_black.png";
|
||||
// break;
|
||||
// case '2':
|
||||
// // Hardware
|
||||
// objectFilename="src/de/heatup/resources/images/25x25_red.png";
|
||||
// break;
|
||||
// case '-':
|
||||
// // Wall
|
||||
// objectFilename="src/de/heatup/resources/images/25x25_blue.png";
|
||||
// break;
|
||||
// default:
|
||||
// objectFilename="src/de/heatup/resources/images/25x25_orange.png";
|
||||
// break;
|
||||
// }
|
||||
// System.out.println(objectFilename);
|
||||
// return objectFilename;
|
||||
// }
|
||||
//
|
||||
// /*
|
||||
// * Sets position of object via int x int y
|
||||
// */
|
||||
// public void setPosition(int x, int y) {
|
||||
// System.out.println(x + " " + y + " " + this.getDimensionX() + " " + this.getDimensionY());
|
||||
// this.objectLabel.setBounds(x, y, this.getDimensionX(), this.getDimensionY());
|
||||
// }
|
||||
//
|
||||
// public int getX() {
|
||||
// return this.objectLabel.getX();
|
||||
// }
|
||||
//
|
||||
// public int getY() {
|
||||
// return this.objectLabel.getY();
|
||||
// }
|
||||
//
|
||||
// public int getDimensionX() {
|
||||
// return this.objectImage.getWidth();
|
||||
// }
|
||||
//
|
||||
// public int getDimensionY() {
|
||||
// return this.objectImage.getHeight();
|
||||
// }
|
||||
//
|
||||
// public JLabel getLabel() {
|
||||
// return this.objectLabel;
|
||||
// }
|
||||
//
|
||||
// public char getOjectIdentifier() {
|
||||
// return this.objectIdentifier;
|
||||
// }
|
||||
//
|
||||
// public void setObjectIdentifier(char objectIdentifier) {
|
||||
// this.objectIdentifier = objectIdentifier;
|
||||
// }
|
||||
}
|
||||
+4
-3
@@ -1,4 +1,4 @@
|
||||
package de.heatup.testing;
|
||||
package de.heatup.objects;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
@@ -11,6 +11,7 @@ import de.heatup.logging.Logger;
|
||||
import de.heatup.mapengine.CollisionHandler;
|
||||
import de.heatup.mapengine.MapGrid;
|
||||
import de.heatup.mapengine.MapGridCell;
|
||||
import de.heatup.ui.Main;
|
||||
|
||||
public class Opponent extends Player {
|
||||
|
||||
@@ -79,8 +80,8 @@ public class Opponent extends Player {
|
||||
/*
|
||||
* Spieler identifizieren und auf "direkte Sicht" prüfen
|
||||
*/
|
||||
int playerX = GameLoopD.getPlayer().getGridLocation().x;
|
||||
int playerY = GameLoopD.getPlayer().getGridLocation().y;
|
||||
int playerX = Main.getPlayer().getGridLocation().x;
|
||||
int playerY = Main.getPlayer().getGridLocation().y;
|
||||
char playerDirection = '0';
|
||||
int stepLength = 0;
|
||||
// Richtung bestimmen wenn sich Spieler und Gegner auf einer Achse befinden
|
||||
@@ -1,4 +1,4 @@
|
||||
package de.heatup.testing;
|
||||
package de.heatup.objects;
|
||||
|
||||
import java.awt.BasicStroke;
|
||||
import java.awt.Graphics;
|
||||
@@ -11,7 +11,7 @@ import javax.imageio.ImageIO;
|
||||
import javax.swing.JComponent;
|
||||
|
||||
import de.heatup.cfg.Config;
|
||||
import de.heatup.testing.PanelBuilder;
|
||||
import de.heatup.ui.PanelBuilder;
|
||||
|
||||
/*
|
||||
* Draft for static objects
|
||||
@@ -33,15 +33,12 @@ 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) {
|
||||
@@ -60,7 +57,7 @@ public class StaticObject extends JComponent {
|
||||
// TODO: Check if we can store a rescaled image in bf1???
|
||||
// if ( doRescale ) {
|
||||
// System.out.println("Hit: " + rescaleFactorX + " " + rescaleFactorY);
|
||||
// g2d.scale(rescaleFactorX, rescaleFactorY);
|
||||
g2d.scale(2, 2);
|
||||
// }
|
||||
|
||||
g2d.drawImage(bf1, 0, 0, this);
|
||||
@@ -94,7 +91,9 @@ public class StaticObject extends JComponent {
|
||||
// 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());
|
||||
//this.setBounds(x, y, this.bf1.getWidth(), this.bf1.getHeight());
|
||||
this.setSize(this.bf1.getWidth(), this.bf1.getHeight());
|
||||
this.setLocation(x, y);
|
||||
}
|
||||
|
||||
public String getDebugInfo() {
|
||||
|
||||
@@ -1,99 +0,0 @@
|
||||
package de.heatup.objects;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Random;
|
||||
|
||||
import de.heatup.testing.PanelBuilder;
|
||||
|
||||
|
||||
/*
|
||||
* Static class for opponent movement still quick n' dirty
|
||||
* TODO: Move to other package ex. AI
|
||||
*/
|
||||
public class logic {
|
||||
|
||||
public static void startMovement(final DynamicObject dynObj) {
|
||||
Thread t = new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
int movex=0, movey=0;
|
||||
int move = 0;
|
||||
int dir;
|
||||
int mx, my;
|
||||
Random rand = new Random();
|
||||
while (true) {
|
||||
if ( move == 0 ) {
|
||||
|
||||
dir = rand.nextInt(20)+1;
|
||||
// System.out.println("Entscheidung: " + dir);
|
||||
if ( dir < 5 || dir > 15) {
|
||||
movex = rand.nextInt(800)+1;
|
||||
move = 2;
|
||||
if (movex > 100) { move = -2; }
|
||||
movey = 0;
|
||||
// System.out.println("X " + move + " " + movex);
|
||||
|
||||
} else {
|
||||
movey = rand.nextInt(600)+1;
|
||||
move = 1;
|
||||
if (movey > 100) { move = -1; }
|
||||
movex = 0;
|
||||
// System.out.println("X " + move + " " + movex);
|
||||
}
|
||||
}
|
||||
|
||||
if ( dynObj.getX() <= 0 && move == -2 ) {
|
||||
move = move * -1;
|
||||
}
|
||||
if ( dynObj.getX() >= 752 && move == 2 ) {
|
||||
move = move * -1;
|
||||
}
|
||||
if ( dynObj.getY() <= 0 && move == -1 ) {
|
||||
move = move * -1;
|
||||
}
|
||||
if ( dynObj.getY() >= 552 && move == 1 ) {
|
||||
move = move * -1;
|
||||
}
|
||||
|
||||
// System.out.println("Move " + move + " Movex " + movex + " Movey " + movey);
|
||||
|
||||
if ( move == -2 && movex >= 0) {
|
||||
movex -= 4;
|
||||
mx=-4;
|
||||
my=0;
|
||||
dynObj.setImage(PanelBuilder.getImageLoader().getBufferedImage('l'));
|
||||
} else if ( move == 2 && movex >= 0) {
|
||||
movex -= 4;
|
||||
mx=4;
|
||||
my=0;
|
||||
dynObj.setImage(PanelBuilder.getImageLoader().getBufferedImage('r'));
|
||||
} else if (move == -1 && movey >= 0) {
|
||||
movey -= 4;
|
||||
my=-4;
|
||||
mx=0;
|
||||
dynObj.setImage(PanelBuilder.getImageLoader().getBufferedImage('u'));
|
||||
} else if (move == 1 && movey >= 0) {
|
||||
movey -= 4;
|
||||
my=4;
|
||||
mx=0;
|
||||
dynObj.setImage(PanelBuilder.getImageLoader().getBufferedImage('d'));
|
||||
} else {
|
||||
move = 0;
|
||||
mx=0;
|
||||
my=0;
|
||||
}
|
||||
dynObj.setBounds(dynObj.getX()+mx, dynObj.getY()+my, 36, 64);
|
||||
//System.out.println("x: " + dynObj.getX() + " y: " + dynObj.getY());
|
||||
//System.out.println("h: " + dynObj.getHeight() + " w: " + dynObj.getWidth());
|
||||
try {
|
||||
Thread.sleep(40);
|
||||
} catch (InterruptedException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
t.start();
|
||||
}
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
package de.heatup.testing;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class InstancedObjects {
|
||||
private static ArrayList<Player> objects;
|
||||
|
||||
public InstancedObjects() {
|
||||
objects = new ArrayList<Player>();
|
||||
}
|
||||
|
||||
public ArrayList<Player> getObjects() {
|
||||
return objects;
|
||||
}
|
||||
|
||||
public void addObject(Player object) {
|
||||
InstancedObjects.objects.add(object);
|
||||
}
|
||||
}
|
||||
@@ -1,100 +0,0 @@
|
||||
package de.heatup.testing;
|
||||
|
||||
import java.awt.Point;
|
||||
|
||||
import javax.swing.JPanel;
|
||||
|
||||
import de.heatup.mapengine.MapEngine;
|
||||
import de.heatup.mapengine.SpawnAssistant;
|
||||
import de.heatup.objects.ImageLoader;
|
||||
import de.heatup.ui.KeyBindings;
|
||||
import de.heatup.ui.StatusPanelAdder;
|
||||
import de.heatup.ui.actionPanel.ActionControl;
|
||||
|
||||
public class PanelBuilder {
|
||||
private static JPanel actionPanel;
|
||||
private static JPanel outerPanel;
|
||||
private static JPanel statusPanel;
|
||||
private static JPanel gamePanel;
|
||||
|
||||
public static KeyBindings kb;
|
||||
|
||||
public static Player player01;
|
||||
|
||||
private static InstancedObjects instancedObjects;
|
||||
private static ImageLoader imageLoader;
|
||||
|
||||
public static InstancedObjects getInstancedObjects() {
|
||||
return instancedObjects;
|
||||
}
|
||||
|
||||
public static void tick() {
|
||||
|
||||
}
|
||||
|
||||
public static void setPanels(JPanel actionPanel, JPanel outerPanel, JPanel statusPanel, JPanel gamePanel) {
|
||||
PanelBuilder.actionPanel = actionPanel;
|
||||
PanelBuilder.outerPanel = outerPanel;
|
||||
PanelBuilder.statusPanel = statusPanel;
|
||||
PanelBuilder.gamePanel = gamePanel;
|
||||
}
|
||||
public static void startMenu() {
|
||||
|
||||
// StatusPanel bauen
|
||||
StatusPanelAdder.setPanel(statusPanel);
|
||||
StatusPanelAdder.createPanel();
|
||||
|
||||
// ActionPanel bauen
|
||||
ActionControl.setPanel(actionPanel);
|
||||
|
||||
|
||||
createGame(1); /* wird eigentlich vom menue aufgerufen */
|
||||
|
||||
}
|
||||
private static void createGame(int map) {
|
||||
|
||||
instancedObjects = new InstancedObjects();
|
||||
|
||||
imageLoader = new ImageLoader();
|
||||
|
||||
player01 = new Player(); // !!! PLAYER IMMER ZUERST INSTANZIIEREN, DANACH OPPONENTS !!!
|
||||
gamePanel.add(player01);
|
||||
player01.setBounds(25,25,25, 25); // !!! MUSS DRIN BLEIBEN TROTZ NACHTRÄGLICHES SPAWN UMSETZEN !!!
|
||||
|
||||
instancedObjects.getObjects().add(player01);
|
||||
|
||||
// Gegner hinzufügen
|
||||
|
||||
for (int i = 0; i<4; i++) {
|
||||
Opponent newOpponent = new Opponent();
|
||||
gamePanel.add(newOpponent);
|
||||
newOpponent.setBounds(50, 50, 25, 25);
|
||||
instancedObjects.getObjects().add(newOpponent);
|
||||
}
|
||||
|
||||
|
||||
|
||||
kb = new KeyBindings(player01);
|
||||
statusPanel.addKeyListener(kb);
|
||||
|
||||
MapEngine me;
|
||||
if (map > 0) {
|
||||
me = new MapEngine(map);
|
||||
} else {
|
||||
me = new MapEngine();
|
||||
}
|
||||
me.addAllToPanel(gamePanel);
|
||||
|
||||
|
||||
for (Player movingObject : instancedObjects.getObjects()) {
|
||||
Point spawnPoint = SpawnAssistant.getPathLocationOnGrid();
|
||||
movingObject.spawnAt(spawnPoint);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public static ImageLoader getImageLoader() {
|
||||
return imageLoader;
|
||||
}
|
||||
}
|
||||
@@ -6,8 +6,7 @@ import java.awt.event.KeyEvent;
|
||||
import sun.awt.resources.awt;
|
||||
import de.heatup.mapengine.CollisionHandler;
|
||||
import de.heatup.mapengine.MapGrid;
|
||||
import de.heatup.testing.GameLoopD;
|
||||
import de.heatup.testing.Player;
|
||||
import de.heatup.objects.Player;
|
||||
import de.heatup.ui.actionPanel.ActionControl;
|
||||
import de.heatup.ui.actionPanel.ActionWatcher;
|
||||
import de.heatup.ui.actionPanel.HardewareManipulate;
|
||||
@@ -83,8 +82,8 @@ public class KeyBindings extends KeyAdapter {
|
||||
esc = true;
|
||||
break;
|
||||
case KeyEvent.VK_A:
|
||||
if(((MapGrid.getGridCell(GameLoopD.player01.getGridLocation().x, GameLoopD.player01.getGridLocation().y).isTrigger()
|
||||
&& !HardewareManipulate.getHardware(MapGrid.getGridCell(GameLoopD.player01.getGridLocation().x, GameLoopD.player01.getGridLocation().y).getCorrespondingHardwareToTrigger()))&&!key)&&ActionControl.getKeyA()){
|
||||
if(((MapGrid.getGridCell(Main.player01.getGridLocation().x, Main.player01.getGridLocation().y).isTrigger()
|
||||
&& !HardewareManipulate.getHardware(MapGrid.getGridCell(Main.player01.getGridLocation().x, Main.player01.getGridLocation().y).getCorrespondingHardwareToTrigger()))&&!key)&&ActionControl.getKeyA()){
|
||||
ActionWatcher.setAction(true);
|
||||
key=true;
|
||||
}
|
||||
@@ -192,7 +191,7 @@ public class KeyBindings extends KeyAdapter {
|
||||
}
|
||||
if (isESC()) {
|
||||
System.out.println("ESC pressed.");
|
||||
GameLoopD.pause();
|
||||
Main.pause();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +1,12 @@
|
||||
package de.heatup.testing;
|
||||
package de.heatup.ui;
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Color;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.EventQueue;
|
||||
import java.awt.GraphicsConfiguration;
|
||||
import java.awt.GraphicsDevice;
|
||||
import java.awt.GraphicsEnvironment;
|
||||
import java.awt.GridLayout;
|
||||
import java.awt.Point;
|
||||
|
||||
@@ -15,20 +19,20 @@ import de.heatup.mapengine.CollisionHandler;
|
||||
import de.heatup.mapengine.MapEngine;
|
||||
import de.heatup.mapengine.MapGrid;
|
||||
import de.heatup.mapengine.SpawnAssistant;
|
||||
import de.heatup.objects.Player;
|
||||
import de.heatup.objects.StaticObject;
|
||||
import de.heatup.timers.HardwareResetTimers;
|
||||
import de.heatup.ui.KeyBindings;
|
||||
import de.heatup.ui.StatusPanelAdder;
|
||||
import de.heatup.ui.actionPanel.ActionControl;
|
||||
import de.heatup.ui.actionPanel.ActionWatcher;
|
||||
|
||||
|
||||
public class GameLoopD extends JFrame implements Runnable {
|
||||
public class Main extends JFrame implements Runnable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private boolean running = false;
|
||||
private static boolean pause = false;
|
||||
private boolean fullscreen = true;
|
||||
|
||||
private Thread thread;
|
||||
|
||||
@@ -41,13 +45,22 @@ public class GameLoopD extends JFrame implements Runnable {
|
||||
private static JPanel outerPanel;
|
||||
private static JPanel statusPanel;
|
||||
private static JPanel gamePanel;
|
||||
private static JPanel leftPanel;
|
||||
private static JPanel rightPanel;
|
||||
private static JPanel actionPanel;
|
||||
|
||||
public GameLoopD(){
|
||||
public Main(){
|
||||
setTitle("HeatUP!");
|
||||
setDefaultCloseOperation(EXIT_ON_CLOSE);
|
||||
setResizable(false);
|
||||
|
||||
/*
|
||||
* Vorbedingungen welche gesetzt sein müssen, damit Fullscreen möglich wird.
|
||||
*/
|
||||
if ( fullscreen) {
|
||||
setResizable(false);
|
||||
setUndecorated(true);
|
||||
}
|
||||
|
||||
outerPanel = new JPanel();
|
||||
outerPanel.setLayout(new BorderLayout());
|
||||
@@ -61,13 +74,24 @@ public class GameLoopD extends JFrame implements Runnable {
|
||||
gamePanel.setLayout(null);
|
||||
gamePanel.setPreferredSize(new Dimension(800,600));
|
||||
gamePanel.setFocusable(false);
|
||||
gamePanel.setBackground(Color.black);
|
||||
|
||||
actionPanel = new JPanel();
|
||||
actionPanel.setLayout(new GridLayout(1,1));
|
||||
actionPanel.setPreferredSize(new Dimension(800,80));
|
||||
actionPanel.setFocusable(true);
|
||||
|
||||
leftPanel = new JPanel();
|
||||
leftPanel.setLayout(null);
|
||||
leftPanel.setBackground(Color.black);
|
||||
|
||||
rightPanel = new JPanel();
|
||||
rightPanel.setLayout(null);
|
||||
rightPanel.setBackground(Color.black);
|
||||
|
||||
outerPanel.add(statusPanel,BorderLayout.NORTH);
|
||||
outerPanel.add(leftPanel, BorderLayout.WEST);
|
||||
outerPanel.add(rightPanel, BorderLayout.EAST);
|
||||
outerPanel.add(gamePanel,BorderLayout.CENTER);
|
||||
outerPanel.add(actionPanel,BorderLayout.SOUTH);
|
||||
|
||||
@@ -87,11 +111,21 @@ public class GameLoopD extends JFrame implements Runnable {
|
||||
player01 = PanelBuilder.player01;
|
||||
|
||||
|
||||
actionPanel.setVisible(true);
|
||||
/*
|
||||
* Wenn die Variable fullscreen gesetzt ist, wir er hier eingeschaltet.
|
||||
*/
|
||||
if ( fullscreen ) {
|
||||
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
|
||||
GraphicsDevice gd = ge.getDefaultScreenDevice();
|
||||
GraphicsConfiguration gc = gd.getDefaultConfiguration();
|
||||
gd.setFullScreenWindow(this);
|
||||
leftPanel.setPreferredSize(new Dimension(((gd.getDisplayMode().getWidth() - (int)gamePanel.getPreferredSize().getWidth())/2), 0));
|
||||
rightPanel.setPreferredSize(new Dimension(((gd.getDisplayMode().getWidth() - (int)gamePanel.getPreferredSize().getWidth())/2), 0));
|
||||
}
|
||||
outerPanel.setVisible(true);
|
||||
statusPanel.setVisible(true);
|
||||
gamePanel.setVisible(true);
|
||||
|
||||
actionPanel.setVisible(true);
|
||||
statusPanel.setVisible(true);
|
||||
}
|
||||
|
||||
|
||||
@@ -106,7 +140,7 @@ public class GameLoopD extends JFrame implements Runnable {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
final GameLoopD frame = new GameLoopD();
|
||||
final Main frame = new Main();
|
||||
frame.repaint();
|
||||
Thread ht= new Thread(){
|
||||
|
||||
@@ -8,8 +8,8 @@ import de.heatup.mapengine.MapEngine;
|
||||
import de.heatup.mapengine.SpawnAssistant;
|
||||
import de.heatup.objects.ImageLoader;
|
||||
import de.heatup.objects.InstancedObjects;
|
||||
import de.heatup.testing.Opponent;
|
||||
import de.heatup.testing.Player;
|
||||
import de.heatup.objects.Opponent;
|
||||
import de.heatup.objects.Player;
|
||||
import de.heatup.ui.actionPanel.ActionControl;
|
||||
|
||||
public class PanelBuilder {
|
||||
|
||||
@@ -21,7 +21,7 @@ import de.heatup.ui.statusPanel.Timer;
|
||||
|
||||
public class StatusPanelAdder{
|
||||
private static JPanel panel;
|
||||
private static int hgap=30;
|
||||
private static int hgap=32;
|
||||
private static int vgap=9;
|
||||
private static int modifier=-1;
|
||||
private static int temping=0;
|
||||
@@ -73,15 +73,24 @@ public class StatusPanelAdder{
|
||||
newPanel.setLayout(new FlowLayout(FlowLayout.CENTER, hgap,5));
|
||||
panel=newPanel;
|
||||
}
|
||||
/**
|
||||
* erhöht die Anzahl Manipulationen
|
||||
*/
|
||||
public static void addManipulations(){
|
||||
manipulations+=1;
|
||||
Score.raiseScore(25);
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @return anzahl Manipulationen
|
||||
*/
|
||||
public static int getManipulations(){
|
||||
return manipulations;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* tick-Methode für das StatusPanel
|
||||
*/
|
||||
public static void tick() {
|
||||
Timer.tickTimer();
|
||||
timeLabel.setText(Timer.getMinuteS() + ":" + Timer.getSecondsS());
|
||||
|
||||
@@ -7,7 +7,7 @@ import java.awt.Font;
|
||||
import javax.swing.*;
|
||||
|
||||
import de.heatup.mapengine.MapGrid;
|
||||
import de.heatup.testing.GameLoopD;
|
||||
import de.heatup.ui.Main;
|
||||
|
||||
public class ActionControl{
|
||||
private static int count = 0;
|
||||
@@ -112,7 +112,7 @@ public class ActionControl{
|
||||
}else{
|
||||
resetActionPanel();
|
||||
actionLabel.setText("Manipulation erfolgreich!");
|
||||
HardewareManipulate.setHardware(MapGrid.getGridCell(GameLoopD.player01.getGridLocation().x, GameLoopD.player01.getGridLocation().y).getCorrespondingHardwareToTrigger());
|
||||
HardewareManipulate.setHardware(MapGrid.getGridCell(Main.player01.getGridLocation().x, Main.player01.getGridLocation().y).getCorrespondingHardwareToTrigger());
|
||||
}
|
||||
}
|
||||
private static void setAchiv(){
|
||||
|
||||
@@ -2,8 +2,9 @@ package de.heatup.ui.actionPanel;
|
||||
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import de.heatup.mapengine.MapGrid;
|
||||
import de.heatup.testing.GameLoopD;
|
||||
import de.heatup.ui.Main;
|
||||
|
||||
public class ActionWatcher{
|
||||
private static boolean action = false;
|
||||
@@ -17,28 +18,28 @@ public class ActionWatcher{
|
||||
return action;
|
||||
}
|
||||
public static void tick(){
|
||||
//Infotext, wenn man in der nähe von einem Hardwareteil steht
|
||||
if(MapGrid.getGridCell(GameLoopD.player01.getGridLocation().x, GameLoopD.player01.getGridLocation().y).isTrigger() && !action && !setAction){
|
||||
//Infotext, wenn man in der n�he von einem Hardwareteil steht
|
||||
if(MapGrid.getGridCell(Main.player01.getGridLocation().x, Main.player01.getGridLocation().y).isTrigger() && !action && !setAction){
|
||||
infoText=true;
|
||||
if(!HardewareManipulate.getHardware(MapGrid.getGridCell(GameLoopD.player01.getGridLocation().x, GameLoopD.player01.getGridLocation().y).getCorrespondingHardwareToTrigger())){
|
||||
if(!HardewareManipulate.getHardware(MapGrid.getGridCell(Main.player01.getGridLocation().x, Main.player01.getGridLocation().y).getCorrespondingHardwareToTrigger())){
|
||||
ActionControl.setTextforA();
|
||||
}else{
|
||||
ActionControl.setTextforManipulate();
|
||||
}
|
||||
}
|
||||
//Entfernt InfoText
|
||||
if(!MapGrid.getGridCell(GameLoopD.player01.getGridLocation().x, GameLoopD.player01.getGridLocation().y).isTrigger() && infoText){
|
||||
if(!MapGrid.getGridCell(Main.player01.getGridLocation().x, Main.player01.getGridLocation().y).isTrigger() && infoText){
|
||||
ActionControl.resetActionPanel();
|
||||
infoText=false;
|
||||
}
|
||||
//Leitet das Manipulieren ein, nachdem man das "A" gedrückt hat. Es kommt entweder Smashing oder Keysequence Text.
|
||||
//Leitet das Manipulieren ein, nachdem man das "A" gedr�ckt hat. Es kommt entweder Smashing oder Keysequence Text.
|
||||
if(action&&!setAction){
|
||||
setAction=true;
|
||||
ActionControl.resetActionPanel();
|
||||
ActionControl.setAction(new Random().nextInt(2)+1);
|
||||
}
|
||||
//Entfernt jeglichen Text wenn man sich von dem Hardwarestück entfernt, nachdem Aktion bereits eingeleitet wurde, und setzt Booleans/Counter wieder auf die Ausgangssituation
|
||||
if(!MapGrid.getGridCell(GameLoopD.player01.getGridLocation().x, GameLoopD.player01.getGridLocation().y).isTrigger() && setAction){
|
||||
//Entfernt jeglichen Text wenn man sich von dem Hardwarest�ck entfernt, nachdem Aktion bereits eingeleitet wurde, und setzt Booleans/Counter wieder auf die Ausgangssituation
|
||||
if(!MapGrid.getGridCell(Main.player01.getGridLocation().x, Main.player01.getGridLocation().y).isTrigger() && setAction){
|
||||
ActionControl.resetActionPanel();
|
||||
ActionControl.resetKeyA();
|
||||
infoText=false;
|
||||
|
||||
Reference in New Issue
Block a user