32 lines
577 B
Java
32 lines
577 B
Java
|
|
/**
|
|
* Klasse Pacman.
|
|
*
|
|
* @author
|
|
*/
|
|
public class Pacman {
|
|
/*---------------Attribute-----*/
|
|
int x;
|
|
int y;
|
|
Game game;
|
|
int gameFrame;
|
|
|
|
/*---------------Konstruktor---*/
|
|
public Pacman(Game game) {
|
|
x = 20; y = 20;
|
|
this.game = game;
|
|
}
|
|
|
|
/*---------------Methoden------*/
|
|
public void keyPressed(int keyCode) {
|
|
if (keyCode == game.LEFT) {
|
|
x += game.cellSize;
|
|
}
|
|
}
|
|
|
|
public void draw() {
|
|
gameFrame++;
|
|
game.render.drawPacman(x, y, (gameFrame/12) % 2 == 0);
|
|
}
|
|
}
|