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() comment3.target=void\ draw()
comment4.params= comment4.params=
comment4.target=void\ keyPressed() comment4.target=void\ keyPressed()
comment5.params=ox\ oy\ nx\ ny comment5.params=
comment5.target=boolean\ wantMove(int,\ int,\ int,\ int) comment5.target=void\ keyReleased()
comment6.params= comment6.params=ox\ oy\ nx\ ny
comment6.target=void\ populateWalls() comment6.target=boolean\ wantMove(int,\ int,\ int,\ int)
numComments=7 comment7.params=
comment7.target=void\ populateWalls()
numComments=8

View File

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