Web games

From CongDon1207/AGENTS.md · View interactive version

Web games is an AI agent skill from the GitHub repository CongDon1207/AGENTS.md. Web browser game development principles. Framework selection, WebGPU, optimization, PWA.

How to use this skill

Skill file

Web Browser Game Development

Framework selection and browser-specific principles.


1. Framework Selection

Decision Tree

What type of game?
│
├── 2D Game
│   ├── Full game engine features? → Phaser
│   └── Raw rendering power? → PixiJS
│
├── 3D Game
│   ├── Full engine (physics, XR)? → Babylon.js
│   └── Rendering focused? → Three.js
│
└── Hybrid / Canvas
    └── Custom → Raw Canvas/WebGL

Comparison (2025)

| Framework | Type | Best For |

|-----------|------|----------|

| Phaser 4 | 2D | Full game features |

| PixiJS 8 | 2D | Rendering, UI |

| Three.js | 3D | Visualizations, lightweight |

| Babylon.js 7 | 3D | Full engine, XR |


2. WebGPU Adoption

Browser Support (2025)

| Browser | Support |

|---------|---------|

| Chrome | ✅ Since v113 |

| Edge | ✅ Since v113 |

| Firefox | ✅ Since v131 |

| Safari | ✅ Since 18.0 |

| Total | ~73% global |

Decision


3. Performance Principles

Browser Constraints

| Constraint | Strategy |

|------------|----------|

| No local file access | Asset bundling, CDN |

| Tab throttling | Pause when hidden |

| Mobile data limits | Compress assets |

| Audio autoplay | Require user interaction |

Optimization Priority

  1. Asset compression - KTX2, Draco, WebP
  2. Lazy loading - Load on demand
  3. Object pooling - Avoid GC
  4. Draw call batching - Reduce state changes
  5. Web Workers - Offload heavy computation

4. Asset Strategy

Compression Formats

| Type | Format |

|------|--------|

| Textures | KTX2 + Basis Universal |

| Audio | WebM/Opus (fallback: MP3) |

| 3D Models | glTF + Draco/Meshopt |

Loading Strategy

| Phase | Load |

|-------|------|

| Startup | Core assets, <2MB |

| Gameplay | Stream on demand |

| Background | Prefetch next level |


5. PWA for Games

Benefits

Requirements


6. Audio Handling

Browser Requirements

Best Practices


7. Anti-Patterns

| ❌ Don't | ✅ Do |

|----------|-------|

| Load all assets upfront | Progressive loading |

| Ignore tab visibility | Pause when hidden |

| Block on audio load | Lazy load audio |

| Skip compression | Compress everything |

| Assume fast connection | Handle slow networks |


Remember: Browser is the most accessible platform. Respect its constraints.

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.