|
@ -4,7 +4,20 @@ public class GhostBehaviorRandom implements GhostBehavior { |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
public Vector2 GetDirection(Ghost ghost) { |
|
|
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; |
|
|
return null; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|