- NEVER deviate from the defined RGB values in
HEATMAP_SYSTEM_SPEC.md - Use exact color matching with 5-pixel tolerance maximum
- All heatmap files must use pure colors - no anti-aliasing or gradients
levels/sidescroller/[stage]/sections/[section]/heatmaps/
├── ground.png # REQUIRED - Black (0,0,0)
├── kill.png # REQUIRED - Red (255,0,0)
├── semisolid.png # REQUIRED - Yellow (255,255,0)
├── spawn.png # REQUIRED - Blue (0,0,255)
├── friction.png # OPTIONAL - Cyan/Magenta
├── hazard.png # OPTIONAL - Orange/Purple
├── bounce.png # OPTIONAL - Green
├── speed.png # OPTIONAL - White
└── special.png # OPTIONAL - Gray
- Required heatmaps: Load with error (game won't start without them)
- Optional heatmaps: Load with try/catch (game continues if missing)
- Performance: Cache all loaded heatmaps in memory
- Validation: Log successful loads, warn on missing optional files
- Heatmap effects are checked BEFORE collision detection
- Multiple effects can stack (e.g., friction + hazard on same pixel)
- Use cooldowns to prevent effect spam
- Effects are applied based on player hurtbox positions
// ALWAYS use this pattern for color matching
const color = getPixelColor(x, y, imageData);
if (color && color.a > 128) { // Check alpha first
if (colorsMatch(color, HEATMAP_COLORS.CYAN)) {
// Apply effect
}
}- Hazard effects: 0.5-1.0 second cooldowns
- Speed boosts: 0.2 second cooldowns
- Special effects: 2.0 second cooldowns
- Bounce effects: No cooldown (physics-based)
- ❌ Create heatmaps with custom colors not in the spec
- ❌ Mix multiple effects in a single heatmap file
- ❌ Use anti-aliased or gradient colors
- ❌ Skip the try/catch for optional heatmap loading
- ❌ Apply effects without cooldown management
- ❌ Check heatmap effects after collision detection
- ❌ Don't sample every pixel - use 6-pixel step for performance
- ❌ Don't check heatmaps when player is stationary
- ❌ Don't load heatmaps larger than level dimensions
- ❌ Don't create heatmaps with unnecessary transparency
- Update
HEATMAP_SYSTEM_SPEC.mdwith new color definitions - Add loading code in
js/game-assets.jswith try/catch - Add state variables in
js/game-state.js - Implement physics logic in
js/physics.jscheckHeatmapEffects() - Update this document with new rules
- All required heatmaps load without errors
- Optional heatmaps fail gracefully when missing
- Color detection works with exact RGB values
- Effects trigger at correct player positions
- Cooldowns prevent effect spam
- Multiple effects work together correctly
- Performance remains stable with all heatmaps active
// Enable detailed heatmap logging
console.log(`[Heatmap] Loaded ${heatmapType} for ${sectionKey}`);
console.log(`[Heatmap] Effect triggered: ${effectType} at (${x}, ${y})`);
console.log(`[Heatmap] Color detected: RGB(${r}, ${g}, ${b})`);- Use browser dev tools to inspect loaded image data
- Verify pixel colors match exact RGB specifications
- Check that transparency is handled correctly
- Existing
ground.png,kill.png,semisolid.png,spawn.pngremain unchanged - New heatmap types are purely additive
- No breaking changes to existing level files
- Backward compatibility maintained
- Heatmap system is designed for easy extension
- New effects can be added without modifying core physics
- Color system can be expanded with new combinations
- Performance optimizations can be added without breaking functionality
Remember: The heatmap system is designed to give level designers visual control over game physics. Keep it simple, consistent, and extensible!