Skip to content

Commit

Permalink
Fixed walls, now they are grey instead of boxes
Browse files Browse the repository at this point in the history
  • Loading branch information
Nico-242 committed Oct 7, 2024
1 parent f5b6f38 commit c0b6369
Show file tree
Hide file tree
Showing 8 changed files with 94 additions and 82 deletions.
4 changes: 2 additions & 2 deletions create1.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ function create1() {

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

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

for (i = 0; i < arr3.length; i++){
for(j=0; j < arr3[i].length; j++){
if (arr3[i][j] == 1){
wall.create(j*40+20, i*40+20, "wall");
}
if(arr3[i][j]==9){
wall.create(j*40+20,i*40+20, "wall");
}
else if (arr3[i][j] == 1){
wall.create(j*40+20, i*40+20, "void");
}
//adding guard to that position
else if(arr3[i][j]==3){
//adds the guards to the array of guards
Expand Down
5 changes: 4 additions & 1 deletion create4.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,12 @@ function create4() {

for(i=0; i<arr4.length; i++){
for(j=0;j<arr4[i].length;j++){
if(arr4[i][j]==1){
if(arr4[i][j]==9){
wall.create(j*40+20,i*40+20, "wall");
}
else if (arr4[i][j] == 1){
wall.create(j*40+20, i*40+20, "void");
}
//adding GUARD to that position
else if(arr4[i][j]==3){
guards = this.physics.add.sprite(j*40+20,i*40+8, "guard").setScale(guardScale);
Expand Down
5 changes: 4 additions & 1 deletion create5.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,12 @@ function create5() {

for(i=0; i<arr5.length; i++){
for(j=0;j<arr5[i].length;j++){
if(arr5[i][j]==1){
if(arr5[i][j]==9){
wall.create(j*40+20,i*40+20, "wall");
}
else if (arr5[i][j] == 1){
wall.create(j*40+20, i*40+20, "void");
}
//adding GUARD to that position
else if(arr5[i][j]==3){
//adds the guards to the array of guards
Expand Down
2 changes: 1 addition & 1 deletion createDemo.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ function createDemo() {

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

}
Expand Down
139 changes: 71 additions & 68 deletions grid.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@
//3 is guard
//2 is robber
//4 is the gem
//5 is flashlight guard
//5 is horizontal flashlight guard
//6 is vertical flashlight beam
//7 is horizontal flashlight beam
//7 is horizontal flashlight guard
//8 is vertical flashlight guard
//9 is void

//level 1
let demo = [
[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,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,7,7,7,7],
[7,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,7],
[7,0,3,0,0,0,2,0,0,0,0,0,0,4,0,0,0,3,0,7],
[7,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,7],
[7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7],
[9,9,9,9,9,9,9,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deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -289,29 +289,29 @@ function checkBounds(dir) {
wrongMove = false;
//get potential next move based on the direction
if (dir == "up"){
if (currentBoard[playerRow - 1][playerCol] == 7){
if (currentBoard[playerRow - 1][playerCol] == 9){
wrongMove = true;
} else {
checkGuard(playerRow - 1, playerCol);
}

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

0 comments on commit c0b6369

Please sign in to comment.