diff --git a/HeatUp/src/de/heatup/testing/Opponent.java b/HeatUp/src/de/heatup/testing/Opponent.java index 2f4b008..b2844a5 100644 --- a/HeatUp/src/de/heatup/testing/Opponent.java +++ b/HeatUp/src/de/heatup/testing/Opponent.java @@ -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;