From 2c9409826b5d61b53ce533b57e76904dc3a96799 Mon Sep 17 00:00:00 2001 From: elioat Date: Tue, 24 Dec 2024 17:04:28 -0500 Subject: * --- html/rogue/js/world.js | 46 +++++++++++++++++++++++++++++----------------- 1 file changed, 29 insertions(+), 17 deletions(-) diff --git a/html/rogue/js/world.js b/html/rogue/js/world.js index fb29e27..789b5f4 100644 --- a/html/rogue/js/world.js +++ b/html/rogue/js/world.js @@ -112,7 +112,6 @@ const GRASS_TYPES = { type: 'grass', width: 30, height: 40, - blades: 5, color: '#33aa55', shadowColor: '#229944' }, @@ -120,7 +119,6 @@ const GRASS_TYPES = { type: 'grass', width: 20, height: 25, - blades: 4, color: '#33bb66', shadowColor: '#22aa55' }, @@ -128,7 +126,6 @@ const GRASS_TYPES = { type: 'grass', width: 30, height: 40, - blades: 5, color: '#eebb33', shadowColor: '#cc9922' }, @@ -136,7 +133,6 @@ const GRASS_TYPES = { type: 'grass', width: 20, height: 25, - blades: 4, color: '#ffcc44', shadowColor: '#ddaa33' }, @@ -144,7 +140,6 @@ const GRASS_TYPES = { type: 'grass', width: 30, height: 40, - blades: 5, color: '#44aaff', shadowColor: '#2299ff', glowing: true @@ -153,7 +148,6 @@ const GRASS_TYPES = { type: 'grass', width: 20, height: 25, - blades: 4, color: '#55bbff', shadowColor: '#33aaff', glowing: true @@ -848,22 +842,35 @@ const renderRock = (ctx, rock, groundY) => { // Add grass rendering function const renderGrass = (ctx, grass, groundY, time) => { const { x, config } = grass; - const { width, height, blades, color, shadowColor, glowing } = config; + const { width, height, color, shadowColor, glowing } = config; // Get or initialize grass state const stateKey = `grass_${x}`; if (!window.gameState.world.grassStates[stateKey]) { + // Ensure blade count is between 4 and 8 (inclusive) + const minBlades = 4; + const maxBlades = 8; + // Use Math.round instead of Math.floor and ensure positive value + const randomValue = Math.abs(seededRandom(x, height)); + const bladeCount = minBlades + Math.round(randomValue * (maxBlades - minBlades)); + window.gameState.world.grassStates[stateKey] = { rustleAmount: 0, - rustleDecay: 0.95 + rustleDecay: 0.95, + bladeCount: bladeCount }; } const state = window.gameState.world.grassStates[stateKey]; - + + // Additional validation as a safety net + if (!state.bladeCount || state.bladeCount < 4) { + state.bladeCount = 4; + } + // Check for player interaction const player = window.gameState.player; const interactionDistance = width; - const distanceToPlayer = Math.abs(player.x + player.width/2 - x); + const distanceToPlayer = Math.abs(player.x + player.width / 2 - x); if (distanceToPlayer < interactionDistance) { state.rustleAmount = Math.min(1, state.rustleAmount + 0.3); @@ -875,17 +882,22 @@ const renderGrass = (ctx, grass, groundY, time) => { if (glowing) { ctx.save(); ctx.shadowColor = color; - ctx.shadowBlur = 10 + Math.sin(time/500) * 3; // Pulsing glow effect + ctx.shadowBlur = 10 + Math.sin(time/500) * 3; } // Draw each blade of grass - for (let i = 0; i < blades; i++) { - const bladeX = x + (i - blades/2) * (width/blades); - const bladeWidth = width / blades * 0.7; + for (let i = 0; i < state.bladeCount; i++) { + // Calculate blade width - consistent regardless of blade count + const bladeWidth = width / 5 * 0.7; + + // Calculate blade position - cluster them together more tightly + const spreadFactor = 0.7; // Reduces the spread to create tighter clumps + const centerOffset = (i - (state.bladeCount - 1) / 2) * (width * spreadFactor / state.bladeCount); + const bladeX = x + centerOffset; // Calculate blade curve based on rustle and time - const rustleOffset = Math.sin(time/300 + i) * 5 * state.rustleAmount; - const baseWave = Math.sin(time/1000 + i) * 2; + const rustleOffset = Math.sin(time / 300 + i) * 5 * state.rustleAmount; + const baseWave = Math.sin(time / 1000 + i) * 2; // Draw blade ctx.fillStyle = i % 2 === 0 ? color : shadowColor; @@ -894,7 +906,7 @@ const renderGrass = (ctx, grass, groundY, time) => { // Control points for quadratic curve const cp1x = bladeX + rustleOffset + baseWave; - const cp1y = groundY - height/2; + const cp1y = groundY - height / 2; const cp2x = bladeX + rustleOffset * 1.5 + baseWave; const cp2y = groundY - height; -- cgit 1.4.1-2-gfad0 /mu/commit/409print-float.mu?h=hlt&id=ba8ee517b7ae1da5cc15d0d619fa564f767c8bca'>ba8ee517 ^
b8d613e7 ^






f5e1656d ^
8766aa12 ^
b8d613e7 ^


7cfd2b36 ^
fac93a64 ^
8766aa12 ^

7cfd2b36 ^

fac93a64 ^
8766aa12 ^

7cfd2b36 ^

fac93a64 ^
8766aa12 ^

7cfd2b36 ^

fac93a64 ^
8766aa12 ^

3ff2e99c ^

8766aa12 ^
3ff2e99c ^


7cfd2b36 ^
fac93a64 ^
8766aa12 ^

7cfd2b36 ^


8766aa12 ^

7cfd2b36 ^


8766aa12 ^

7cfd2b36 ^


8766aa12 ^

3ff2e99c ^

8766aa12 ^
b8d613e7 ^


b8d613e7 ^
8766aa12 ^

b8d613e7 ^

8766aa12 ^
b8d613e7 ^


b8d613e7 ^


8766aa12 ^

b8d613e7 ^

8766aa12 ^
b8d613e7 ^


b8d613e7 ^




8766aa12 ^

b8d613e7 ^

8766aa12 ^
b8d613e7 ^


b8d613e7 ^


8766aa12 ^

b8d613e7 ^

8766aa12 ^
b8d613e7 ^


b8d613e7 ^


8766aa12 ^

b8d613e7 ^

8766aa12 ^
b8d613e7 ^





b4932228 ^
b8d613e7 ^




b4932228 ^
b8d613e7 ^




b4932228 ^
b8d613e7 ^




b4932228 ^
b8d613e7 ^



3ff2e99c ^

b8d613e7 ^

fac93a64 ^
b4932228 ^
b8d613e7 ^








8766aa12 ^
b8d613e7 ^
3ff2e99c ^
b8d613e7 ^



8766aa12 ^
b8d613e7 ^





3ff2e99c ^
b8d613e7 ^

f5e1656d ^
b8d613e7 ^







b8d613e7 ^
a3f77915 ^
b8d613e7 ^
8766aa12 ^
b8d613e7 ^
8766aa12 ^
a3f77915 ^
b8d613e7 ^
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196