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()
|
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
|
||||||
|
|||||||
14
game.java
14
game.java
@ -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) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user