diff options
Diffstat (limited to 'html')
-rw-r--r-- | html/rogue/js/world.js | 69 |
1 files changed, 57 insertions, 12 deletions
diff --git a/html/rogue/js/world.js b/html/rogue/js/world.js index ad25e9d..e6d8b6e 100644 --- a/html/rogue/js/world.js +++ b/html/rogue/js/world.js @@ -93,6 +93,40 @@ const GRASS_TYPES = { blades: 4, color: '#3b6', shadowColor: '#2a5' + }, + GOLDEN_TALL: { + type: 'grass', + width: 30, + height: 40, + blades: 5, + color: '#eb3', + shadowColor: '#c92' + }, + GOLDEN_SHORT: { + type: 'grass', + width: 20, + height: 25, + blades: 4, + color: '#fc4', + shadowColor: '#da3' + }, + BLUE_TALL: { + type: 'grass', + width: 30, + height: 40, + blades: 5, + color: '#4af', + shadowColor: '#29f', + glowing: true + }, + BLUE_SHORT: { + type: 'grass', + width: 20, + height: 25, + blades: 4, + color: '#5bf', + shadowColor: '#3af', + glowing: true } }; @@ -251,22 +285,22 @@ const createWorld = () => ({ ], backgroundGrass: [ { type: WORLD_OBJECTS.GRASS_BACKGROUND, x: -350, config: GRASS_TYPES.SHORT }, - { type: WORLD_OBJECTS.GRASS_BACKGROUND, x: -180, config: GRASS_TYPES.TALL }, + { type: WORLD_OBJECTS.GRASS_BACKGROUND, x: -180, config: GRASS_TYPES.GOLDEN_TALL }, { type: WORLD_OBJECTS.GRASS_BACKGROUND, x: 100, config: GRASS_TYPES.TALL }, - { type: WORLD_OBJECTS.GRASS_BACKGROUND, x: 320, config: GRASS_TYPES.SHORT }, - { type: WORLD_OBJECTS.GRASS_BACKGROUND, x: 580, config: GRASS_TYPES.TALL }, - { type: WORLD_OBJECTS.GRASS_BACKGROUND, x: 750, config: GRASS_TYPES.SHORT }, + { type: WORLD_OBJECTS.GRASS_BACKGROUND, x: 320, config: GRASS_TYPES.BLUE_SHORT }, + { type: WORLD_OBJECTS.GRASS_BACKGROUND, x: 580, config: GRASS_TYPES.GOLDEN_SHORT }, + { type: WORLD_OBJECTS.GRASS_BACKGROUND, x: 750, config: GRASS_TYPES.BLUE_TALL }, { type: WORLD_OBJECTS.GRASS_BACKGROUND, x: 950, config: GRASS_TYPES.TALL }, - { type: WORLD_OBJECTS.GRASS_BACKGROUND, x: 1050, config: GRASS_TYPES.SHORT } + { type: WORLD_OBJECTS.GRASS_BACKGROUND, x: 1050, config: GRASS_TYPES.GOLDEN_TALL } ], foregroundGrass: [ - { type: WORLD_OBJECTS.GRASS_FOREGROUND, x: -280, config: GRASS_TYPES.TALL }, - { type: WORLD_OBJECTS.GRASS_FOREGROUND, x: -50, config: GRASS_TYPES.SHORT }, + { type: WORLD_OBJECTS.GRASS_FOREGROUND, x: -280, config: GRASS_TYPES.BLUE_TALL }, + { type: WORLD_OBJECTS.GRASS_FOREGROUND, x: -50, config: GRASS_TYPES.GOLDEN_SHORT }, { type: WORLD_OBJECTS.GRASS_FOREGROUND, x: 150, config: GRASS_TYPES.TALL }, - { type: WORLD_OBJECTS.GRASS_FOREGROUND, x: 420, config: GRASS_TYPES.SHORT }, - { type: WORLD_OBJECTS.GRASS_FOREGROUND, x: 680, config: GRASS_TYPES.TALL }, + { type: WORLD_OBJECTS.GRASS_FOREGROUND, x: 420, config: GRASS_TYPES.BLUE_SHORT }, + { type: WORLD_OBJECTS.GRASS_FOREGROUND, x: 680, config: GRASS_TYPES.GOLDEN_TALL }, { type: WORLD_OBJECTS.GRASS_FOREGROUND, x: 880, config: GRASS_TYPES.SHORT }, - { type: WORLD_OBJECTS.GRASS_FOREGROUND, x: 1150, config: GRASS_TYPES.TALL } + { type: WORLD_OBJECTS.GRASS_FOREGROUND, x: 1150, config: GRASS_TYPES.BLUE_TALL } ], // Track grass animation states grassStates: {} @@ -376,7 +410,7 @@ 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 } = config; + const { width, height, blades, color, shadowColor, glowing } = config; // Get or initialize grass state const stateKey = `grass_${x}`; @@ -399,6 +433,13 @@ const renderGrass = (ctx, grass, groundY, time) => { state.rustleAmount *= state.rustleDecay; } + // Add glow effect for blue grass + if (glowing) { + ctx.save(); + ctx.shadowColor = color; + ctx.shadowBlur = 10 + Math.sin(time/500) * 3; // Pulsing glow effect + } + // Draw each blade of grass for (let i = 0; i < blades; i++) { const bladeX = x + (i - blades/2) * (width/blades); @@ -406,7 +447,7 @@ const renderGrass = (ctx, grass, groundY, time) => { // 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; // Gentle wave motion + const baseWave = Math.sin(time/1000 + i) * 2; // Draw blade ctx.fillStyle = i % 2 === 0 ? color : shadowColor; @@ -424,6 +465,10 @@ const renderGrass = (ctx, grass, groundY, time) => { ctx.quadraticCurveTo(cp1x + bladeWidth, cp1y, bladeX + bladeWidth, groundY); ctx.fill(); } + + if (glowing) { + ctx.restore(); + } }; // Collision detection helper |