more collision detection!!!
This commit is contained in:
1 parent
f95a85cf2e
commit
8770014845
2 files changed
+11
No files matched your search
@@ -1,9 +1,12 @@
|
||||
package de.heatup.mapengine;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import de.heatup.logging.Logger;
|
||||
import de.heatup.testing.Player;
|
||||
|
||||
public class CollisionHandler {
|
||||
private static ArrayList<Player> movingObjects = new ArrayList<Player>();
|
||||
/**
|
||||
* Prüfe ob eine Kollision vorliegt
|
||||
* @param movingObject Kann alles sein, dass sich bewegt. Spieler oder KI.
|
||||
@@ -36,4 +39,7 @@ public class CollisionHandler {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
public static void addMovingObject(Player movingObject) {
|
||||
movingObjects.add(movingObject);
|
||||
}
|
||||
}
|
||||
@@ -14,6 +14,7 @@ import javax.swing.JComponent;
|
||||
|
||||
import de.heatup.cfg.Config;
|
||||
import de.heatup.logging.Logger;
|
||||
import de.heatup.mapengine.CollisionHandler;
|
||||
|
||||
public class Player extends JComponent {
|
||||
private static final long serialVersionUID = 1L;
|
||||
@@ -33,6 +34,10 @@ public class Player extends JComponent {
|
||||
int stepCounter = 25;
|
||||
private Point currentGridPosition;
|
||||
|
||||
public Player() {
|
||||
CollisionHandler.addMovingObject(this);
|
||||
}
|
||||
|
||||
public void setSpeedMultiplicator(int factor) {
|
||||
this.speedMultiplicator *= factor;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user