update movement
This commit is contained in:
parent
f17b27e0b5
commit
80d3681a2a
BIN
game.class
BIN
game.class
Binary file not shown.
12
game.ctxt
12
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
|
||||
|
||||
14
game.java
14
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) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user