John Haugabook

Game Engine

開發程式設計v1.0.0
作者:John Haugabook更新於 2026-05-11game-engine@clawhub_jhauga/game-engine
程式碼生成前端開發#Game#Javascript#Audio

據 AlphaMoat 統計,截至 2026-09,Game Engine 累計下載 2,617 次、獲 4 個星標,在全部 5,078 個 AI 技能中排名第 4,008 位,在「開發程式設計」分類(577 個)中排名第 500 位。

累計安裝
103
累計下載
2617
星標
4
全站排名
#4,008
全站前 79% · 「開發程式設計」前 87%
平台累計安裝累計下載星標評論
ClawHub ↗6723952-
SkillHub ↗10326174—

各平台的計數口徑不同,統計時間不一致。

這個技能是做什麼的

它涵蓋遊戲迴圈、渲染、輸入控制、物理與碰撞檢測、音訊和多人功能,並提供 2D/3D 開發、測試與釋出的工作步驟;文件還列出模板和參考資料。實際實現需根據目標瀏覽器、裝置能力及所選框架驗證相容性和效能。

資料釋出於 2026-10-29

可以用來做什麼

  • 搭建遊戲主迴圈、輸入處理與渲染流程。
  • 選擇 Canvas、WebGL 或 SVG 等繪圖技術。
  • 規劃碰撞檢測、音效、裝置控制和釋出測試。

什麼時候用

  • 需要使用網頁技術建立或擴充套件 2D/3D 遊戲時。
  • 需要排查渲染、碰撞、音訊或觸控輸入問題時。
  • 準備面向多瀏覽器或裝置釋出遊戲時,需要執行相容性和效能測試時。

示例提示詞

以下是根據技能文件生成的示例,不代表實際執行結果。

為一個簡單的平台遊戲列出主迴圈、輸入、碰撞和渲染模組,不生成或釋出檔案。
根據目標裝置比較 Canvas 與 WebGL 的實現考量。

月度資料趨勢

累計下載2617
644170427632026-03 · 累計下載 7902026-05 · 累計下載 14742026-06 · 累計下載 16882026-07 · 累計下載 20192026-08 · 累計下載 22282026-09 · 累計下載 261726-0326-09
星標4
2342026-03 · 星標 22026-05 · 星標 32026-06 · 星標 32026-07 · 星標 42026-08 · 星標 42026-09 · 星標 426-0326-09

2026-09 起統計方法調整:同名技能按作者分別統計,並覆蓋全部技能。圖中虛線為調整前的月份,與之後的資料不直接比較,也不計算跨越調整的增長。

月份累計下載環比星標
2026-092617—4
2026-082228+10.4%4
2026-072019+19.6%4
2026-061688+14.5%3
2026-051474—3
2026-03790—2

SKILL.md 原文

以下是作者釋出的原始檔案,按純文字顯示,本站未做修改或稽核;其中的連結不可點選,命令請核實後再執行。抓取於 2026-10-23。

6.2 KB · ClawHub v1.0.0
---
name: game-engine
description: 'Expert skill for building web-based game engines and games using HTML5, Canvas, WebGL, and JavaScript. Use when asked to create games, build game engines, implement game physics, handle collision detection, set up game loops, manage sprites, add game controls, or work with 2D/3D rendering. Covers techniques for platformers, breakout-style games, maze games, tilemaps, audio, multiplayer via WebRTC, and publishing games.'
---

# Game Engine Skill

Build web-based games and game engines using HTML5 Canvas, WebGL, and JavaScript. This skill includes starter templates, reference documentation, and step-by-step workflows for 2D and 3D game development with frameworks such as Phaser, Three.js, Babylon.js, and A-Frame.

## When to Use This Skill
展開全部(共 140 行)

- Building a game engine or game from scratch using web technologies
- Implementing game loops, physics, collision detection, or rendering
- Working with HTML5 Canvas, WebGL, or SVG for game graphics
- Adding game controls (keyboard, mouse, touch, gamepad)
- Creating 2D platformers, breakout-style games, maze games, or 3D experiences
- Working with tilemaps, sprites, or animations
- Adding audio to web games
- Implementing multiplayer features with WebRTC or WebSockets
- Optimizing game performance
- Publishing and distributing web games

## Prerequisites

- Basic knowledge of HTML, CSS, and JavaScript
- A modern web browser with Canvas/WebGL support
- A text editor or IDE
- Optional: Node.js for build tooling and local development servers

## Core Concepts

The following concepts form the foundation of every web-based game engine.

### Game Loop

Every game engine revolves around the game loop -- a continuous cycle of:

1. **Process Input** - Read keyboard, mouse, touch, or gamepad input
2. **Update State** - Update game object positions, physics, AI, and logic
3. **Render** - Draw the current game state to the screen

Use `requestAnimationFrame` for smooth, browser-optimized rendering.

### Rendering

- **Canvas 2D** - Best for 2D games, sprite-based rendering, and tilemaps
- **WebGL** - Hardware-accelerated 3D and advanced 2D rendering
- **SVG** - Vector-based graphics, good for UI elements
- **CSS** - Useful for DOM-based game elements and transitions

### Physics and Collision Detection

- **2D Collision Detection** - AABB, circle, and SAT-based collision
- **3D Collision Detection** - Bounding box, bounding sphere, and raycasting
- **Velocity and Acceleration** - Basic Newtonian physics for movement
- **Gravity** - Constant downward acceleration for platformers

### Controls

- **Keyboard** - Arrow keys, WASD, and custom key bindings
- **Mouse** - Click, move, and pointer lock for FPS-style controls
- **Touch** - Mobile touch events and virtual joysticks
- **Gamepad** - Gamepad API for controller support

### Audio

- **Web Audio API** - Programmatic sound generation and spatial audio
- **HTML5 Audio** - Simple audio playback for music and sound effects

## Step-by-Step Workflows

### Creating a Basic 2D Game

1. Set up an HTML file with a `<canvas>` element
2. Get the 2D rendering context
3. Implement the game loop using `requestAnimationFrame`
4. Create game objects with position, velocity, and size properties
5. Handle keyboard/mouse input for player control
6. Implement collision detection between game objects
7. Add scoring, lives, and win/lose conditions
8. Add sound effects and music

### Building a 3D Game

1. Choose a framework (Three.js, Babylon.js, A-Frame, or PlayCanvas)
2. Set up the scene, camera, and renderer
3. Load or create 3D models and textures
4. Implement lighting and shaders
5. Add physics and collision detection
6. Implement player controls and camera movement
7. Add audio and visual effects

### Publishing a Game

1. Optimize assets (compress images, minify code)
2. Test across browsers and devices
3. Choose distribution platform (web, app stores, game portals)
4. Implement monetization if needed
5. Promote through game communities and social media

## Game Templates

Starter templates are available in the `assets/` folder. Each template provides a complete, working example that can be used as a starting point for a new project.

| Template | Description |
|----------|-------------|
| `paddle-game-template.md` | 2D Breakout-style game with pure JavaScript |
| `2d-maze-game.md` | Maze game with device orientation controls |
| `2d-platform-game.md` | Platformer game using Phaser framework |
| `gameBase-template-reop.md` | Game base template repository structure |
| `simple-2d-engine.md` | Simple 2D platformer engine with collisions |

## Reference Documentation

Detailed reference material is available in the `references/` folder. Consult these files for in-depth coverage of specific topics.

| Reference | Topics Covered |
|-----------|---------------|
| `basics.md` | Game development introduction and anatomy |
| `web-apis.md` | Canvas, WebGL, Web Audio, Gamepad, and other web APIs |
| `techniques.md` | Collision detection, tilemaps, async scripts, audio |
| `3d-web-games.md` | 3D theory, frameworks, shaders, WebXR |
| `game-control-mechanisms.md` | Touch, keyboard, mouse, and gamepad controls |
| `game-publishing.md` | Distribution, promotion, and monetization |
| `algorithms.md` | Raycasting, collision, physics, vector math |
| `terminology.md` | Game development glossary |
| `game-engine-core-principals.md` | Core design principles for game engines |

## Troubleshooting

| Issue | Solution |
|-------|----------|
| Canvas is blank | Check that you are calling drawing methods after getting the context and inside the game loop |
| Game runs at different speeds | Use delta time in update calculations instead of fixed values |
| Collision detection is inconsistent | Use continuous collision detection or reduce time steps for fast-moving objects |
| Audio does not play | Browsers require user interaction before playing audio; trigger playback from a click handler |
| Performance is poor | Profile with browser dev tools, reduce draw calls, use object pooling, and optimize asset sizes |
| Touch controls are unresponsive | Prevent default touch behavior and handle touch events separately from mouse events |
| WebGL context lost | Handle the `webglcontextlost` event and restore state on `webglcontextrestored` |

「開發程式設計」分類下的熱門技能

John Haugabook 的其他技能

資料月份:2026-09 · 下載/星標/安裝數聚合自公開技能註冊庫(ClawHub、SkillHub),按月更新。口徑說明見資料方法。