Skip to content

Instantly share code, notes, and snippets.

/Game.java Secret

Created May 29, 2017 01:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/bcec07a68fb61af7c1f6d35395873921 to your computer and use it in GitHub Desktop.
Save anonymous/bcec07a68fb61af7c1f6d35395873921 to your computer and use it in GitHub Desktop.
/**
* 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