update game
This commit is contained in:
parent
d78d3c5538
commit
299c5ffffd
BIN
game.class
BIN
game.class
Binary file not shown.
18
game.java
18
game.java
@ -10,18 +10,23 @@ public class Game extends PApplet{
|
||||
/*---------------Attribute-----*/
|
||||
int cellSize = 40;
|
||||
Render render;
|
||||
Pacman pacman;
|
||||
public Pacman pacman;
|
||||
|
||||
boolean pressed = false;
|
||||
int kCode;
|
||||
int gameFrame = 0;
|
||||
int[][] wall;
|
||||
Ghost[] ghosts;
|
||||
/*---------------Konstruktor---*/
|
||||
public Game() {
|
||||
String[] processingArgs = {"MySketch"};
|
||||
PApplet.runSketch(processingArgs, this);
|
||||
render = new Render(this);
|
||||
pacman = new Pacman(this);
|
||||
ghosts = new Ghost[4];
|
||||
for (int i = 0; i < 4; i++) {
|
||||
ghosts[i] = new Ghost(this, cellSize / 2 + cellSize * (i + 4), 300);
|
||||
}
|
||||
render = new Render(this);
|
||||
populateWalls();
|
||||
}
|
||||
|
||||
@ -36,8 +41,15 @@ public class Game extends PApplet{
|
||||
gameFrame ++;
|
||||
|
||||
if (pressed && gameFrame % 15 == 0) pacman.keyPressed(kCode);
|
||||
|
||||
if (gameFrame % 30 == 0) {
|
||||
for (int i = 0; i < 4; i++) {
|
||||
ghosts[i].move();
|
||||
}
|
||||
}
|
||||
background(0);
|
||||
for (int i = 0; i < 4; i++) {
|
||||
ghosts[i].draw();
|
||||
}
|
||||
pacman.draw();
|
||||
for (int i = 0; i < wall.length; i++) {
|
||||
render.drawWall(wall[i]);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user