-
-
Save anonymous/bcec07a68fb61af7c1f6d35395873921 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Simple game of pacman that collects dots | |
*/ | |
public class Game | |
{ | |
// Instances | |
private Dot dot1, dot2, dot3; | |
private Player player; | |
//Constructors | |
public Game(int x, int y) | |
{ | |
player = new Player(x, y); | |
dot1 = new Dot(1, 1); | |
dot2 = new Dot(2, 2); | |
dot3 = new Dot(3, 3); | |
} | |
public void move(int dx, int dy) | |
{ | |
player.move(dx, dy); | |
player.collect(dot1); | |
player.collect(dot2); | |
player.collect(dot3); | |
} | |
public String toString() | |
{ | |
return player + | |
" " + | |
dot1 + | |
" " + | |
dot2 + | |
" " + | |
dot3; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment