CommanderLazarus commited on
Commit
a7c5b6a
·
verified ·
1 Parent(s): 6b74c43

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
Files changed (2) hide show
  1. script.js +17 -4
  2. style.css +4 -10
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
- const isWall = Math.random() < 0.4 &&
47
- i !== playerPosition &&
48
- i !== waterPosition &&
49
- i !== CELL_COUNT - 1; // Don't block start, end or water
 
 
 
 
 
 
 
 
 
 
 
 
 
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
- aspect-ratio: 1/1;
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
- background-image: linear-gradient(45deg, #4ade80 25%, #22c55e 25%, #22c55e 50%, #4ade80 50%, #4ade80 75%, #22c55e 75%, #22c55e 100%);
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;