diff --git a/game.class b/game.class index 1eedc25..9abc098 100644 Binary files a/game.class and b/game.class differ diff --git a/game.ctxt b/game.ctxt index 7d7c866..b821b17 100644 --- a/game.ctxt +++ b/game.ctxt @@ -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 diff --git a/game.java b/game.java index 372acbc..3195b10 100644 --- a/game.java +++ b/game.java @@ -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) {