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-----*/
|
/*---------------Attribute-----*/
|
||||||
int cellSize = 40;
|
int cellSize = 40;
|
||||||
Render render;
|
Render render;
|
||||||
Pacman pacman;
|
public Pacman pacman;
|
||||||
|
|
||||||
boolean pressed = false;
|
boolean pressed = false;
|
||||||
int kCode;
|
int kCode;
|
||||||
int gameFrame = 0;
|
int gameFrame = 0;
|
||||||
int[][] wall;
|
int[][] wall;
|
||||||
|
Ghost[] ghosts;
|
||||||
/*---------------Konstruktor---*/
|
/*---------------Konstruktor---*/
|
||||||
public Game() {
|
public Game() {
|
||||||
String[] processingArgs = {"MySketch"};
|
String[] processingArgs = {"MySketch"};
|
||||||
PApplet.runSketch(processingArgs, this);
|
PApplet.runSketch(processingArgs, this);
|
||||||
render = new Render(this);
|
|
||||||
pacman = new Pacman(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();
|
populateWalls();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -36,8 +41,15 @@ public class Game extends PApplet{
|
|||||||
gameFrame ++;
|
gameFrame ++;
|
||||||
|
|
||||||
if (pressed && gameFrame % 15 == 0) pacman.keyPressed(kCode);
|
if (pressed && gameFrame % 15 == 0) pacman.keyPressed(kCode);
|
||||||
|
if (gameFrame % 30 == 0) {
|
||||||
|
for (int i = 0; i < 4; i++) {
|
||||||
|
ghosts[i].move();
|
||||||
|
}
|
||||||
|
}
|
||||||
background(0);
|
background(0);
|
||||||
|
for (int i = 0; i < 4; i++) {
|
||||||
|
ghosts[i].draw();
|
||||||
|
}
|
||||||
pacman.draw();
|
pacman.draw();
|
||||||
for (int i = 0; i < wall.length; i++) {
|
for (int i = 0; i < wall.length; i++) {
|
||||||
render.drawWall(wall[i]);
|
render.drawWall(wall[i]);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user