fdai2751
11 months ago
6 changed files with 95 additions and 10 deletions
-
5src/main/java/pacmanGame/GameManager.java
-
6src/main/java/pacmanGame/Ghost.java
-
2src/main/java/pacmanGame/GhostBehavior.java
-
8src/main/java/pacmanGame/GhostBehaviorChase.java
-
24src/main/java/pacmanGame/GhostBehaviorRandom.java
-
58src/main/java/pacmanGame/VisualizerPlainText.java
@ -1,7 +1,7 @@ |
|||
package pacmanGame; |
|||
|
|||
public interface GhostBehavior { |
|||
public Vector2 GetDirection(); |
|||
public Vector2 GetDirection(Ghost ghost); |
|||
|
|||
|
|||
} |
@ -0,0 +1,24 @@ |
|||
package pacmanGame; |
|||
import java.util.Random; |
|||
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; |
|||
} |
|||
|
|||
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue