mirror of
https://github.com/jokerx3/HeatUp
synced 2026-07-27 12:19:45 +02:00
Collision Opponent angepasst
This commit is contained in:
@@ -107,29 +107,26 @@ public class Opponent extends Player {
|
||||
testY=this.getGridLocation().y + i;
|
||||
testX=this.getGridLocation().x;
|
||||
}
|
||||
|
||||
// Umwandeln der numerischen Darstellung der Richtung und CollisionHandler verständlich Angabe
|
||||
// charDir = ( d == 'x' && i == -1 ) ? 'l' : 'r';
|
||||
// charDir = ( d == 'y' && i == -1 ) ? 'u' : 'd';
|
||||
// if (CollisionHandler.checkCollision(this, charDir)) {
|
||||
// System.out.println("Kollision!");
|
||||
// this.setGridLocation(testX, testY);
|
||||
// this.prevd = d;
|
||||
// this.previ = i;
|
||||
// redecide = false;
|
||||
// animate = true;
|
||||
// break;
|
||||
// }
|
||||
|
||||
// Testen ob die gewählte Richtung begehbar ist
|
||||
if (MapGrid.getGridCell(testX,testY).isPath()) {
|
||||
|
||||
if ( d == 'x' && i == -1 ) {
|
||||
charDir = 'l';
|
||||
} else if ( d == 'x' && i == 1 ) {
|
||||
charDir = 'r';
|
||||
} else if ( d == 'y' && i == -1 ) {
|
||||
charDir = 'u';
|
||||
} else if ( d == 'y' && i == 1 ) {
|
||||
charDir = 'd';
|
||||
}
|
||||
|
||||
if (CollisionHandler.checkCollision(this, charDir)) {
|
||||
System.out.println("Kollision!");
|
||||
this.setGridLocation(testX, testY);
|
||||
this.prevd = d;
|
||||
this.previ = i;
|
||||
redecide = false;
|
||||
animate = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -159,6 +156,7 @@ public class Opponent extends Player {
|
||||
}
|
||||
if (stepCounter <= 0) {
|
||||
stepCounter = 25;
|
||||
|
||||
if ( ! MapGrid.getGridCell(newx,newy).isPath()) {
|
||||
redecide = true;
|
||||
animate = false;
|
||||
|
||||
Reference in New Issue
Block a user