跳到主要内容
知仓学习社ZHICANG

web-games

>-

不碰外部(只输出文字)无严重或高危命中sickn33/agentic-awesome-skills

它会碰到什么

扫了多少1 个文本文件,4 KB
它会碰到什么不碰外部(只输出文字)
命中总数0 处
命中统计严重 0 · 高 0 · 中 0 · 低 0

这一栏是扫描器报的事实,不是结论。命中多不等于有毒(安全工具、规则库、示例脚本本来就会包含危险写法),命中少也不等于干净。它和你手上的凭据、文件、网络有什么关系,需要你自己看。

技能内容

Web Browser Game Development

> Framework selection and browser-specific principles. For stack choice details see game-development/engine-selection.


1. Framework Selection

Decision Tree

What type of game?
│
├── 2D Game
│   ├── Full game engine features? → Phaser 4
│   ├── Fast prototype / jam?      → Kaplay
│   ├── Raw rendering power?       → PixiJS 8
│   └── Tiny / no dependency?      → Raw Canvas / WebGL
│
├── 3D Game
│   ├── Full engine (physics, XR)? → Babylon.js
│   └── Rendering focused?         → Three.js
│
├── Hybrid (DOM UI + canvas moments)
│   └── Custom shell + guest viewport
│       (Canvas/Kaplay/Phaser/Pixi inside a region/modal)
│
└── Narrative-first
    └── Ink (inkjs) or Twine export + DOM host

Comparison

| Framework | Type | Best For |

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

| Raw Canvas / WebGL | 2D / low-level | Small scope, full control |

| Kaplay | 2D toolkit | Rapid prototypes |

| Phaser 4 | 2D engine | Full game features |

| PixiJS 8 | 2D renderer | Rendering, custom systems |

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

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

Hybrid shell + guest

Use when chrome is HTML (menus, inventories, text, dashboards) but bursts of play need a canvas:

  1. Mount guest in a container; pass context in.
  2. Run a local game loop in the guest.
  3. Return results (score, pass/fail); destroy guest (RAF, listeners, GL context as needed).

Do not let the guest own global app routing unless the product is a full-screen game.


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

  • New GPU-heavy projects: Use WebGPU with WebGL fallback
  • Broad legacy / simple 2D: Start with WebGL or Canvas 2D
  • Feature detection: Check navigator.gpu

3. Performance Principles

Browser Constraints

| Constraint | Strategy |

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

| No local file access | Asset bundling, CDN |

| Tab throttling | Pause when hidden (visibilitychange) |

| 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

| Type | Format |

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

| Textures | KTX2 + Basis Universal (or WebP/PNG for simple 2D) |

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

| 3D Models | glTF + Draco/Meshopt |

| Phase | Load |

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

| Startup | Core assets, <2MB |

| Gameplay | Stream on demand |

| Background | Prefetch next level |


5. PWA for Games

Benefits: offline play, install, fullscreen, optional push.

Requirements: service worker, web app manifest, HTTPS.


6. Audio Handling

  • Create/resume AudioContext on first click/tap
  • Prefer Web Audio API; pool sources; preload common SFX
  • Compress with WebM/Opus when possible

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 |

| Leave canvas engines running off-screen | Tear down guests |


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

When to Use

Use when building HTML5/WebGL/WebGPU games, choosing a browser runtime, or wiring hybrid DOM+canvas guests.

Limitations

  • Use this skill only when the task clearly matches the scope described above.
  • Do not treat the output as a substitute for environment-specific validation, testing, or expert review.
  • Stop and ask for clarification if required inputs, permissions, safety boundaries, or success criteria are missing.

想直接用这个技能?

本站把开放许可(MIT / Apache 等)的技能按仓库打包整理到网盘,点一下转存到你自己的网盘,不用一个个从 GitHub 拉。许可未声明的技能只给原始仓库链接,不打包。

它属于哪个仓库

星标★ 46,490
本站分层T1
该仓技能数6676
原文件路径plugins/agentic-awesome-skills-claude/skills/game-development/web-games/SKILL.md

同一个仓库里的其他技能

看这个仓库的全部 6676 个技能

同名技能的其他版本

有 3 个不同仓库或目录里都有叫 web-games 的技能。它们内容并不相同,别混用: