update game

This commit is contained in:
hihoman23 2026-07-09 12:50:55 +02:00
parent d78d3c5538
commit 299c5ffffd
2 changed files with 15 additions and 3 deletions

Binary file not shown.

View File

@ -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]);