update movement

This commit is contained in:
hihoman23 2026-07-09 11:42:07 +02:00
parent f17b27e0b5
commit 80d3681a2a
3 changed files with 20 additions and 6 deletions

Binary file not shown.

View File

@ -10,8 +10,10 @@ comment3.params=
comment3.target=void\ draw()
comment4.params=
comment4.target=void\ keyPressed()
comment5.params=ox\ oy\ nx\ ny
comment5.target=boolean\ wantMove(int,\ int,\ int,\ int)
comment6.params=
comment6.target=void\ populateWalls()
numComments=7
comment5.params=
comment5.target=void\ keyReleased()
comment6.params=ox\ oy\ nx\ ny
comment6.target=boolean\ wantMove(int,\ int,\ int,\ int)
comment7.params=
comment7.target=void\ populateWalls()
numComments=8

View File

@ -12,6 +12,9 @@ public class Game extends PApplet{
Render render;
Pacman pacman;
boolean pressed = false;
int kCode;
int gameFrame = 0;
int[][] wall;
/*---------------Konstruktor---*/
public Game() {
@ -30,6 +33,10 @@ public class Game extends PApplet{
public void draw() {
gameFrame ++;
if (pressed && gameFrame % 15 == 0) pacman.keyPressed(kCode);
background(0);
pacman.draw();
for (int i = 0; i < wall.length; i++) {
@ -38,7 +45,12 @@ public class Game extends PApplet{
}
public void keyPressed() {
pacman.keyPressed(keyCode);
pressed = true;
kCode = keyCode;
}
public void keyReleased() {
pressed = false;
}
public boolean wantMove(int ox, int oy, int nx, int ny) {