The board needs to be more logical, with the walls as lines, creating a maze that can actually be played. The main character needs to be there for me to play with it, and the board should not be round, but totally square. Correct the earlier mistake by rendering the board as a square instead.
Browse files
script.js
CHANGED
|
@@ -43,10 +43,23 @@ const ENEMY_SCORE = 100;
|
|
| 43 |
cell.className = 'cell';
|
| 44 |
cell.dataset.index = i;
|
| 45 |
// More walls for larger maze
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 50 |
if (isWall) {
|
| 51 |
cell.classList.add('wall');
|
| 52 |
} else {
|
|
|
|
| 43 |
cell.className = 'cell';
|
| 44 |
cell.dataset.index = i;
|
| 45 |
// More walls for larger maze
|
| 46 |
+
// Create maze walls with more structure
|
| 47 |
+
let isWall = false;
|
| 48 |
+
const row = Math.floor(i / GRID_SIZE);
|
| 49 |
+
const col = i % GRID_SIZE;
|
| 50 |
+
|
| 51 |
+
// Border walls
|
| 52 |
+
if (row === 0 || row === GRID_SIZE-1 || col === 0 || col === GRID_SIZE-1) {
|
| 53 |
+
isWall = true;
|
| 54 |
+
}
|
| 55 |
+
// Inner maze walls - every 5th row/col
|
| 56 |
+
else if (row % 5 === 0 || col % 5 === 0) {
|
| 57 |
+
isWall = Math.random() < 0.7;
|
| 58 |
+
}
|
| 59 |
+
// Don't block start, end or water
|
| 60 |
+
if (i === playerPosition || i === waterPosition || i === CELL_COUNT - 1) {
|
| 61 |
+
isWall = false;
|
| 62 |
+
}
|
| 63 |
if (isWall) {
|
| 64 |
cell.classList.add('wall');
|
| 65 |
} else {
|
style.css
CHANGED
|
@@ -5,16 +5,15 @@ body {
|
|
| 5 |
.game-container {
|
| 6 |
max-width: 600px;
|
| 7 |
}
|
| 8 |
-
|
| 9 |
.maze-container {
|
| 10 |
position: relative;
|
| 11 |
width: 100%;
|
| 12 |
-
|
| 13 |
-
border-radius: 50%;
|
| 14 |
overflow: hidden;
|
| 15 |
box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
|
|
|
|
|
|
|
| 16 |
}
|
| 17 |
-
|
| 18 |
.maze-border {
|
| 19 |
position: absolute;
|
| 20 |
top: 0;
|
|
@@ -41,11 +40,9 @@ body {
|
|
| 41 |
position: relative;
|
| 42 |
transition: all 0.2s ease;
|
| 43 |
}
|
| 44 |
-
|
| 45 |
.wall {
|
| 46 |
background-color: #4ade80;
|
| 47 |
-
|
| 48 |
-
background-size: 10px 10px;
|
| 49 |
}
|
| 50 |
.player {
|
| 51 |
background-color: #f0fdf4;
|
|
@@ -83,7 +80,6 @@ body {
|
|
| 83 |
.path {
|
| 84 |
background-color: #f8fafc;
|
| 85 |
}
|
| 86 |
-
|
| 87 |
.game-over {
|
| 88 |
position: absolute;
|
| 89 |
top: 0;
|
|
@@ -97,9 +93,7 @@ body {
|
|
| 97 |
justify-content: center;
|
| 98 |
color: white;
|
| 99 |
z-index: 100;
|
| 100 |
-
border-radius: 50%;
|
| 101 |
}
|
| 102 |
-
|
| 103 |
.game-over h2 {
|
| 104 |
font-size: 2rem;
|
| 105 |
margin-bottom: 1rem;
|
|
|
|
| 5 |
.game-container {
|
| 6 |
max-width: 600px;
|
| 7 |
}
|
|
|
|
| 8 |
.maze-container {
|
| 9 |
position: relative;
|
| 10 |
width: 100%;
|
| 11 |
+
height: 500px;
|
|
|
|
| 12 |
overflow: hidden;
|
| 13 |
box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
|
| 14 |
+
background-color: #f8fafc;
|
| 15 |
+
border: 2px solid #4ade80;
|
| 16 |
}
|
|
|
|
| 17 |
.maze-border {
|
| 18 |
position: absolute;
|
| 19 |
top: 0;
|
|
|
|
| 40 |
position: relative;
|
| 41 |
transition: all 0.2s ease;
|
| 42 |
}
|
|
|
|
| 43 |
.wall {
|
| 44 |
background-color: #4ade80;
|
| 45 |
+
border: 1px solid #22c55e;
|
|
|
|
| 46 |
}
|
| 47 |
.player {
|
| 48 |
background-color: #f0fdf4;
|
|
|
|
| 80 |
.path {
|
| 81 |
background-color: #f8fafc;
|
| 82 |
}
|
|
|
|
| 83 |
.game-over {
|
| 84 |
position: absolute;
|
| 85 |
top: 0;
|
|
|
|
| 93 |
justify-content: center;
|
| 94 |
color: white;
|
| 95 |
z-index: 100;
|
|
|
|
| 96 |
}
|
|
|
|
| 97 |
.game-over h2 {
|
| 98 |
font-size: 2rem;
|
| 99 |
margin-bottom: 1rem;
|