Skip to content

Commit

Permalink
tried to fix walls, problem that void is staying on the levels
Browse files Browse the repository at this point in the history
  • Loading branch information
Nico-242 committed Sep 17, 2024
1 parent 475935c commit f5b6f38
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 23 deletions.
Binary file modified assets/WallBox.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/void.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 4 additions & 1 deletion create1.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,11 @@ function create1() {

for(i=0; i<arr1.length; i++){
for(j=0;j<arr1[i].length;j++){
if(arr1[i][j]==1){
if(arr1[i][j]==7){
wall.create(j*40+20,i*40+20, "wall");
}
else if (arr0[i][j] == 1){
wall.create(j*40+20, i*40+20, "void");
}
//adding gem to that position
else if(arr1[i][j]==4){
Expand Down
5 changes: 4 additions & 1 deletion create2.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,11 @@ function create2() {

for(i=0; i<arr2.length; i++){
for(j=0;j<arr2[i].length;j++){
if(arr2[i][j]==1){
if(arr2[i][j]==7){
wall.create(j*40+20,i*40+20, "wall");
}
else if (arr0[i][j] == 1){
wall.create(j*40+20, i*40+20, "void");
}
//adding guard to that position
else if(arr2[i][j]==3){
Expand Down
5 changes: 4 additions & 1 deletion createDemo.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,13 @@ function createDemo() {

for (i = 0; i < arr0.length; i++){
for(j=0; j < arr0[i].length; j++){
if (arr0[i][j] ==1){
if (arr0[i][j] ==7){
wall.create(j*40+20, i*40+20, "wall");

}
else if (arr0[i][j] == 1){
wall.create(j*40+20, i*40+20, "void");
}
//adding guard to that position
else if(arr0[i][j]==3){
//adds the guards to the array of guards
Expand Down
33 changes: 17 additions & 16 deletions grid.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,32 +9,33 @@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1,1],
[1,1,1,0,4,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1],
[1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1],
[1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,1,1,1],
[1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,1,1,1],
[1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,1,1,1],
[1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1],
[1,1,1,0,2,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1],
[1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1],
[1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1],
[1,1,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,1,1],
[1,1,7,0,0,0,0,0,0,0,0,0,0,0,0,0,0,7,1,1],
[1,1,7,0,4,0,0,0,0,0,0,0,0,0,0,0,0,7,1,1],
[1,1,7,0,0,0,0,0,0,0,0,0,0,0,0,0,0,7,1,1],
[1,1,7,7,7,7,7,7,7,7,7,7,7,7,0,0,0,7,1,1],
[1,1,1,1,1,1,1,1,1,1,1,1,1,7,0,0,0,7,1,1],
[1,1,7,7,7,7,7,7,7,7,7,7,7,7,0,0,0,7,1,1],
[1,1,7,0,0,0,0,0,0,0,0,0,0,0,0,0,0,7,1,1],
[1,1,7,0,2,0,0,0,0,0,0,0,0,0,0,0,0,7,1,1],
[1,1,7,0,0,0,0,0,0,0,0,0,0,0,0,0,0,7,1,1],
[1,1,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,1,1],
[1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1],
[1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1]];

Expand Down
9 changes: 5 additions & 4 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ function preload() {
this.load.image("blueT", "assets/tileBlue.png");
this.load.image("whiteT", "assets/tileWhite.png");
this.load.image("wall", "assets/WallBox.png");
this.load.image("void", "assets/void.png");
this.load.image("jewel", "assets/jewel.png");
// this.load.image("jewelg", "assets/jewelg.png");
this.load.image("GameOver", "assets/Gameover.png");
Expand Down Expand Up @@ -288,29 +289,29 @@ function checkBounds(dir) {
wrongMove = false;
//get potential next move based on the direction
if (dir == "up"){
if (currentBoard[playerRow - 1][playerCol] == 1){
if (currentBoard[playerRow - 1][playerCol] == 7){
wrongMove = true;
} else {
checkGuard(playerRow - 1, playerCol);
}

}
else if (dir == "down"){
if (currentBoard[playerRow + 1][playerCol] == 1){
if (currentBoard[playerRow + 1][playerCol] == 7){
wrongMove = true;
} else {
checkGuard(playerRow + 1, playerCol);
}
}
else if (dir == "left"){
if (currentBoard[playerRow][playerCol - 1] == 1){
if (currentBoard[playerRow][playerCol - 1] == 7){
wrongMove = true;
} else {
checkGuard(playerRow, playerCol - 1);
}
}
else if (dir == "right"){
if (currentBoard[playerRow][playerCol + 1] == 1){
if (currentBoard[playerRow][playerCol + 1] == 7){
wrongMove = true;
} else {
checkGuard(playerRow, playerCol + 1);
Expand Down

0 comments on commit f5b6f38

Please sign in to comment.