Browse Source

added funtion Gohst moving in random stage

remotes/origin/ghostsbehaviour
fdai2751 11 months ago
parent
commit
f74ae35758
  1. 15
      src/main/java/pacmanGame/GhostBehaviorRandom.java

15
src/main/java/pacmanGame/GhostBehaviorRandom.java

@ -4,7 +4,20 @@ public class GhostBehaviorRandom implements GhostBehavior {
@Override
public Vector2 GetDirection(Ghost ghost) {
Random random = new Random();
int direction = random.nextInt(4);
switch(direction) {
case 0: //oben
return new Vector2(0,1);
case 1: //unten
return new Vector2(0,-1);
case 2:// links
return new Vector2(-1,0);
case 3: //rechts
return new Vector2(1,0);
default:
break;
}
return null;
}

Loading…
Cancel
Save