Compare commits

..

No commits in common. "6abf958133db20eebcc0b63fb8e77158c9ff7028" and "7b67dd0737c60d4065ffa9a2383d4a993e1cef54" have entirely different histories.

5 changed files with 4 additions and 36 deletions

Binary file not shown.

View File

@ -19,24 +19,8 @@ public class Pacman {
/*---------------Methoden------*/ /*---------------Methoden------*/
public void keyPressed(int keyCode) { public void keyPressed(int keyCode) {
int oldX = x; int oldY = y;
if (keyCode == game.RIGHT) {
x += game.cellSize;
}
if (keyCode == game.LEFT) { if (keyCode == game.LEFT) {
x -= game.cellSize; x += game.cellSize;
}
x = (x + (10 * game.cellSize)) % (10 * game.cellSize);
if (keyCode == game.UP) {
y -= game.cellSize;
}
if (keyCode == game.DOWN) {
y += game.cellSize;
}
y = (y + (10 * game.cellSize)) % (10 * game.cellSize);
if (!game.wantMove(oldX/game.cellSize, oldY/game.cellSize, x/game.cellSize, y/game.cellSize)) {
x = oldX;
y = oldY;
} }
} }

Binary file not shown.

View File

@ -10,8 +10,8 @@ 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=boolean\ wantMove()
comment6.params= comment6.params=
comment6.target=void\ populateWalls() comment6.target=void\ populateWalls()
numComments=7 numComments=7

View File

@ -38,23 +38,7 @@ public class Game extends PApplet{
pacman.keyPressed(keyCode); pacman.keyPressed(keyCode);
} }
public boolean wantMove(int ox, int oy, int nx, int ny) { public boolean wantMove() {
System.out.println(","+ox+","+ oy+","+ nx+","+ ny);
if (ox == nx && oy > ny) {
int a = oy;
oy = ny;
ny = a;
} else if(ox > nx) {
int a = ox;
ox = nx;
nx = a;
}
for (int i = 0; i < wall.length; i++) {
int[] w = wall[i];
if (w[0] == ox && w[1] == oy && w[2] == nx && w[3] == ny) {
return false;
}
}
return true; return true;
} }