Collision Opponent angepasst

This commit is contained in:
andreas
2014-11-11 15:19:56 +01:00
parent 662ebf8b92
commit 3d9ff06ac4
+12 -14
View File
@@ -108,21 +108,18 @@ public class Opponent extends Player {
testX=this.getGridLocation().x; testX=this.getGridLocation().x;
} }
// Umwandeln der numerischen Darstellung der Richtung und CollisionHandler verständlich Angabe if ( d == 'x' && i == -1 ) {
// charDir = ( d == 'x' && i == -1 ) ? 'l' : 'r'; charDir = 'l';
// charDir = ( d == 'y' && i == -1 ) ? 'u' : 'd'; } else if ( d == 'x' && i == 1 ) {
// if (CollisionHandler.checkCollision(this, charDir)) { charDir = 'r';
// System.out.println("Kollision!"); } else if ( d == 'y' && i == -1 ) {
// this.setGridLocation(testX, testY); charDir = 'u';
// this.prevd = d; } else if ( d == 'y' && i == 1 ) {
// this.previ = i; charDir = 'd';
// redecide = false; }
// animate = true;
// break;
// }
// Testen ob die gewählte Richtung begehbar ist if (CollisionHandler.checkCollision(this, charDir)) {
if (MapGrid.getGridCell(testX,testY).isPath()) { System.out.println("Kollision!");
this.setGridLocation(testX, testY); this.setGridLocation(testX, testY);
this.prevd = d; this.prevd = d;
this.previ = i; this.previ = i;
@@ -159,6 +156,7 @@ public class Opponent extends Player {
} }
if (stepCounter <= 0) { if (stepCounter <= 0) {
stepCounter = 25; stepCounter = 25;
if ( ! MapGrid.getGridCell(newx,newy).isPath()) { if ( ! MapGrid.getGridCell(newx,newy).isPath()) {
redecide = true; redecide = true;
animate = false; animate = false;