mirror of
https://github.com/jokerx3/HeatUp
synced 2026-07-27 10:09:44 +02:00
Merge branch 'master' of github.com:jokerx3/prp
This commit is contained in:
@@ -4,6 +4,11 @@ package de.heatup.cfg;
|
||||
* Bitte hier eure Magicnumbers eintragen
|
||||
*/
|
||||
public class Config {
|
||||
/*
|
||||
* Attribute
|
||||
* de.heatup.ui.GameLoop
|
||||
*/
|
||||
public static int currentTickNr = 0;
|
||||
/*
|
||||
* Attribute
|
||||
* de.heatup.mapengine.*
|
||||
|
||||
@@ -65,9 +65,7 @@ public class CollisionHandler {
|
||||
public static void tick() {
|
||||
for (int i=1; i<movingObjects.size();i++) {
|
||||
if (movingObjects.get(0).getGridLocation().x== movingObjects.get(i).getGridLocation().x && movingObjects.get(0).getGridLocation().y == movingObjects.get(i).getGridLocation().y) {
|
||||
Logger.enableLogging();
|
||||
Logger.write("COLLISION WITH ENEMY");
|
||||
Logger.disableLogging();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,21 +8,24 @@ import java.awt.Point;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JPanel;
|
||||
|
||||
import de.heatup.cfg.Config;
|
||||
import de.heatup.logging.Logger;
|
||||
import de.heatup.mapengine.CollisionHandler;
|
||||
import de.heatup.mapengine.MapEngine;
|
||||
import de.heatup.mapengine.MapGrid;
|
||||
import de.heatup.mapengine.SpawnAssistant;
|
||||
import de.heatup.objects.StaticObject;
|
||||
import de.heatup.ui.KeyBindings;
|
||||
import de.heatup.ui.StatusPanelAdder;
|
||||
import de.heatup.ui.actionPanel.ActionControl;
|
||||
|
||||
|
||||
public class GameLoopD extends JFrame implements Runnable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
|
||||
private boolean running = false;
|
||||
private boolean pause = false;
|
||||
|
||||
private Thread thread;
|
||||
|
||||
@@ -37,6 +40,9 @@ public class GameLoopD extends JFrame implements Runnable {
|
||||
public static Opponent opponent01;
|
||||
public static Opponent opponent02;
|
||||
public static Opponent opponent03;
|
||||
public static Opponent opponent04;
|
||||
public static Opponent opponent05;
|
||||
public static Opponent opponent06;
|
||||
|
||||
|
||||
public static void main(String[] args) {
|
||||
@@ -74,7 +80,6 @@ public class GameLoopD extends JFrame implements Runnable {
|
||||
actionPanel.setPreferredSize(new Dimension(800,80));
|
||||
actionPanel.setFocusable(false);
|
||||
|
||||
|
||||
outerPanel.add(statusPanel,BorderLayout.NORTH);
|
||||
outerPanel.add(gamePanel,BorderLayout.CENTER);
|
||||
outerPanel.add(actionPanel,BorderLayout.SOUTH);
|
||||
@@ -86,6 +91,9 @@ public class GameLoopD extends JFrame implements Runnable {
|
||||
// StatusPanel bauen
|
||||
StatusPanelAdder.setPanel(statusPanel);
|
||||
StatusPanelAdder.createPanel();
|
||||
// ActionPanel bauen
|
||||
ActionControl.setPanel(actionPanel);
|
||||
ActionControl.setAction("foo");
|
||||
|
||||
player01 = new Player(); // !!! PLAYER IMMER ZUERST INSTANZIIEREN, DANACH OPPONENTS !!!
|
||||
// Query.setPlayer(player01);
|
||||
@@ -105,6 +113,18 @@ public class GameLoopD extends JFrame implements Runnable {
|
||||
gamePanel.add(opponent03);
|
||||
opponent03.setBounds(550,450,25,25);
|
||||
|
||||
opponent04 = new Opponent();
|
||||
gamePanel.add(opponent04);
|
||||
opponent04.setBounds(50,50,25,25);
|
||||
|
||||
opponent05 = new Opponent();
|
||||
gamePanel.add(opponent05);
|
||||
opponent05.setBounds(150,150,25,25);
|
||||
|
||||
opponent06 = new Opponent();
|
||||
gamePanel.add(opponent06);
|
||||
opponent06.setBounds(550,450,25,25);
|
||||
|
||||
|
||||
|
||||
kb = new KeyBindings(player01);
|
||||
@@ -122,6 +142,12 @@ public class GameLoopD extends JFrame implements Runnable {
|
||||
opponent02.spawnAt(spawnPoint3);
|
||||
Point spawnPoint4 = SpawnAssistant.getPathLocationOnGrid();
|
||||
opponent03.spawnAt(spawnPoint4);
|
||||
Point spawnPoint5 = SpawnAssistant.getPathLocationOnGrid();
|
||||
opponent04.spawnAt(spawnPoint5);
|
||||
Point spawnPoint6 = SpawnAssistant.getPathLocationOnGrid();
|
||||
opponent05.spawnAt(spawnPoint6);
|
||||
Point spawnPoint7 = SpawnAssistant.getPathLocationOnGrid();
|
||||
opponent06.spawnAt(spawnPoint7);
|
||||
|
||||
actionPanel.setVisible(true);
|
||||
outerPanel.setVisible(true);
|
||||
@@ -137,12 +163,19 @@ public class GameLoopD extends JFrame implements Runnable {
|
||||
* ende
|
||||
*/
|
||||
|
||||
|
||||
frame.repaint();
|
||||
frame.start();
|
||||
}
|
||||
|
||||
private synchronized void start() {
|
||||
public synchronized void pause() {
|
||||
if (pause) {
|
||||
pause = false;
|
||||
} else {
|
||||
pause = true;
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void start() {
|
||||
if (running) {
|
||||
return;
|
||||
}
|
||||
@@ -153,7 +186,7 @@ public class GameLoopD extends JFrame implements Runnable {
|
||||
|
||||
}
|
||||
|
||||
private synchronized void stop() {
|
||||
public synchronized void stop() {
|
||||
if (!running) {
|
||||
return;
|
||||
}
|
||||
@@ -184,7 +217,9 @@ public class GameLoopD extends JFrame implements Runnable {
|
||||
delta += (now-lastTime) / ns;
|
||||
lastTime = now;
|
||||
if (delta >= 1) {
|
||||
if (!pause) {
|
||||
tick();
|
||||
}
|
||||
updates++;
|
||||
delta--;
|
||||
}
|
||||
@@ -192,7 +227,7 @@ public class GameLoopD extends JFrame implements Runnable {
|
||||
frames++;
|
||||
|
||||
try {
|
||||
thread.sleep(10); // entlastet die cpu massiv.
|
||||
thread.sleep(1); // entlastet die cpu massiv.
|
||||
|
||||
} catch (InterruptedException e) {
|
||||
// TODO Auto-generated catch block
|
||||
@@ -211,11 +246,19 @@ public class GameLoopD extends JFrame implements Runnable {
|
||||
}
|
||||
// alles was geupdatet werden muss hier rein
|
||||
private void tick() {
|
||||
if (Config.currentTickNr >= 60) {
|
||||
Config.currentTickNr = 0;
|
||||
} else {
|
||||
Config.currentTickNr++;
|
||||
}
|
||||
kb.checkKeyActivity();
|
||||
player01.tick();
|
||||
opponent01.tick();
|
||||
opponent02.tick();
|
||||
opponent03.tick();
|
||||
opponent04.tick();
|
||||
opponent05.tick();
|
||||
opponent06.tick();
|
||||
CollisionHandler.tick();
|
||||
}
|
||||
// alles was animiert wird hier rein (paints)
|
||||
|
||||
Reference in New Issue
Block a user