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