Skip to content

Commit 76e68a5

Browse files
authored
Merge pull request #792 from jhauga/skill-game-engine
add new skill game-engine
2 parents e62aa82 + aec440c commit 76e68a5

17 files changed

Lines changed: 11121 additions & 1 deletion

.codespellrc

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,13 @@
3434

3535
# FillIn - pdftk-server skill reference file available permission
3636

37-
ignore-words-list = numer,wit,aks,edn,ser,ois,gir,rouge,categor,aline,ative,afterall,deques,dateA,dateB,TE,FillIn,alle,vai
37+
# LOD - Level of Detail
38+
39+
# InOut - template property in skills/game-engine/assets/2d-platform-game.md
40+
41+
# pixelX - template variable in skill/game-engine/assets/simple-2d-engine.md
42+
43+
ignore-words-list = numer,wit,aks,edn,ser,ois,gir,rouge,categor,aline,ative,afterall,deques,dateA,dateB,TE,FillIn,alle,vai,LOD,InOut,pixelX
3844

3945
# Skip certain files and directories
4046

docs/README.skills.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ Skills differ from other primitives by supporting bundled assets (scripts, code
4141
| [fabric-lakehouse](../skills/fabric-lakehouse/SKILL.md) | Use this skill to get context about Fabric Lakehouse and its features for software systems and AI-powered functions. It offers descriptions of Lakehouse data components, organization with schemas and shortcuts, access control, and code examples. This skill supports users in designing, building, and optimizing Lakehouse solutions using best practices. | `references/getdata.md`<br />`references/pyspark.md` |
4242
| [finnish-humanizer](../skills/finnish-humanizer/SKILL.md) | Detect and remove AI-generated markers from Finnish text, making it sound like a native Finnish speaker wrote it. Use when asked to "humanize", "naturalize", or "remove AI feel" from Finnish text, or when editing .md/.txt files containing Finnish content. Identifies 26 patterns (12 Finnish-specific + 14 universal) and 4 style markers. | `references/patterns.md` |
4343
| [fluentui-blazor](../skills/fluentui-blazor/SKILL.md) | Guide for using the Microsoft Fluent UI Blazor component library (Microsoft.FluentUI.AspNetCore.Components NuGet package) in Blazor applications. Use this when the user is building a Blazor app with Fluent UI components, setting up the library, using FluentUI components like FluentButton, FluentDataGrid, FluentDialog, FluentToast, FluentNavMenu, FluentTextField, FluentSelect, FluentAutocomplete, FluentDesignTheme, or any component prefixed with "Fluent". Also use when troubleshooting missing providers, JS interop issues, or theming. | `references/DATAGRID.md`<br />`references/LAYOUT-AND-NAVIGATION.md`<br />`references/SETUP.md`<br />`references/THEMING.md` |
44+
| [game-engine](../skills/game-engine/SKILL.md) | 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. | `assets/2d-maze-game.md`<br />`assets/2d-platform-game.md`<br />`assets/gameBase-template-repo.md`<br />`assets/paddle-game-template.md`<br />`assets/simple-2d-engine.md`<br />`references/3d-web-games.md`<br />`references/algorithms.md`<br />`references/basics.md`<br />`references/game-control-mechanisms.md`<br />`references/game-engine-core-principles.md`<br />`references/game-publishing.md`<br />`references/techniques.md`<br />`references/terminology.md`<br />`references/web-apis.md` |
4445
| [gh-cli](../skills/gh-cli/SKILL.md) | GitHub CLI (gh) comprehensive reference for repositories, issues, pull requests, Actions, projects, releases, gists, codespaces, organizations, extensions, and all GitHub operations from the command line. | None |
4546
| [git-commit](../skills/git-commit/SKILL.md) | Execute git commit with conventional commit message analysis, intelligent staging, and message generation. Use when user asks to commit changes, create a git commit, or mentions "/commit". Supports: (1) Auto-detecting type and scope from changes, (2) Generating conventional commit messages from diff, (3) Interactive commit with optional type/scope/description overrides, (4) Intelligent file staging for logical grouping | None |
4647
| [github-issues](../skills/github-issues/SKILL.md) | Create, update, and manage GitHub issues using MCP tools. Use this skill when users want to create bug reports, feature requests, or task issues, update existing issues, add labels/assignees/milestones, or manage issue workflows. Triggers on requests like "create an issue", "file a bug", "request a feature", "update issue X", or any GitHub issue management task. | `references/templates.md` |

skills/game-engine/SKILL.md

Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
---
2+
name: game-engine
3+
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.'
4+
---
5+
6+
# Game Engine Skill
7+
8+
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.
9+
10+
## When to Use This Skill
11+
12+
- Building a game engine or game from scratch using web technologies
13+
- Implementing game loops, physics, collision detection, or rendering
14+
- Working with HTML5 Canvas, WebGL, or SVG for game graphics
15+
- Adding game controls (keyboard, mouse, touch, gamepad)
16+
- Creating 2D platformers, breakout-style games, maze games, or 3D experiences
17+
- Working with tilemaps, sprites, or animations
18+
- Adding audio to web games
19+
- Implementing multiplayer features with WebRTC or WebSockets
20+
- Optimizing game performance
21+
- Publishing and distributing web games
22+
23+
## Prerequisites
24+
25+
- Basic knowledge of HTML, CSS, and JavaScript
26+
- A modern web browser with Canvas/WebGL support
27+
- A text editor or IDE
28+
- Optional: Node.js for build tooling and local development servers
29+
30+
## Core Concepts
31+
32+
The following concepts form the foundation of every web-based game engine.
33+
34+
### Game Loop
35+
36+
Every game engine revolves around the game loop -- a continuous cycle of:
37+
38+
1. **Process Input** - Read keyboard, mouse, touch, or gamepad input
39+
2. **Update State** - Update game object positions, physics, AI, and logic
40+
3. **Render** - Draw the current game state to the screen
41+
42+
Use `requestAnimationFrame` for smooth, browser-optimized rendering.
43+
44+
### Rendering
45+
46+
- **Canvas 2D** - Best for 2D games, sprite-based rendering, and tilemaps
47+
- **WebGL** - Hardware-accelerated 3D and advanced 2D rendering
48+
- **SVG** - Vector-based graphics, good for UI elements
49+
- **CSS** - Useful for DOM-based game elements and transitions
50+
51+
### Physics and Collision Detection
52+
53+
- **2D Collision Detection** - AABB, circle, and SAT-based collision
54+
- **3D Collision Detection** - Bounding box, bounding sphere, and raycasting
55+
- **Velocity and Acceleration** - Basic Newtonian physics for movement
56+
- **Gravity** - Constant downward acceleration for platformers
57+
58+
### Controls
59+
60+
- **Keyboard** - Arrow keys, WASD, and custom key bindings
61+
- **Mouse** - Click, move, and pointer lock for FPS-style controls
62+
- **Touch** - Mobile touch events and virtual joysticks
63+
- **Gamepad** - Gamepad API for controller support
64+
65+
### Audio
66+
67+
- **Web Audio API** - Programmatic sound generation and spatial audio
68+
- **HTML5 Audio** - Simple audio playback for music and sound effects
69+
70+
## Step-by-Step Workflows
71+
72+
### Creating a Basic 2D Game
73+
74+
1. Set up an HTML file with a `<canvas>` element
75+
2. Get the 2D rendering context
76+
3. Implement the game loop using `requestAnimationFrame`
77+
4. Create game objects with position, velocity, and size properties
78+
5. Handle keyboard/mouse input for player control
79+
6. Implement collision detection between game objects
80+
7. Add scoring, lives, and win/lose conditions
81+
8. Add sound effects and music
82+
83+
### Building a 3D Game
84+
85+
1. Choose a framework (Three.js, Babylon.js, A-Frame, or PlayCanvas)
86+
2. Set up the scene, camera, and renderer
87+
3. Load or create 3D models and textures
88+
4. Implement lighting and shaders
89+
5. Add physics and collision detection
90+
6. Implement player controls and camera movement
91+
7. Add audio and visual effects
92+
93+
### Publishing a Game
94+
95+
1. Optimize assets (compress images, minify code)
96+
2. Test across browsers and devices
97+
3. Choose distribution platform (web, app stores, game portals)
98+
4. Implement monetization if needed
99+
5. Promote through game communities and social media
100+
101+
## Game Templates
102+
103+
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.
104+
105+
| Template | Description |
106+
|----------|-------------|
107+
| `paddle-game-template.md` | 2D Breakout-style game with pure JavaScript |
108+
| `2d-maze-game.md` | Maze game with device orientation controls |
109+
| `2d-platform-game.md` | Platformer game using Phaser framework |
110+
| `gameBase-template-repo.md` | Game base template repository structure |
111+
| `simple-2d-engine.md` | Simple 2D platformer engine with collisions |
112+
113+
## Reference Documentation
114+
115+
Detailed reference material is available in the `references/` folder. Consult these files for in-depth coverage of specific topics.
116+
117+
| Reference | Topics Covered |
118+
|-----------|---------------|
119+
| `basics.md` | Game development introduction and anatomy |
120+
| `web-apis.md` | Canvas, WebGL, Web Audio, Gamepad, and other web APIs |
121+
| `techniques.md` | Collision detection, tilemaps, async scripts, audio |
122+
| `3d-web-games.md` | 3D theory, frameworks, shaders, WebXR |
123+
| `game-control-mechanisms.md` | Touch, keyboard, mouse, and gamepad controls |
124+
| `game-publishing.md` | Distribution, promotion, and monetization |
125+
| `algorithms.md` | Raycasting, collision, physics, vector math |
126+
| `terminology.md` | Game development glossary |
127+
| `game-engine-core-principles.md` | Core design principles for game engines |
128+
129+
## Troubleshooting
130+
131+
| Issue | Solution |
132+
|-------|----------|
133+
| Canvas is blank | Check that you are calling drawing methods after getting the context and inside the game loop |
134+
| Game runs at different speeds | Use delta time in update calculations instead of fixed values |
135+
| Collision detection is inconsistent | Use continuous collision detection or reduce time steps for fast-moving objects |
136+
| Audio does not play | Browsers require user interaction before playing audio; trigger playback from a click handler |
137+
| Performance is poor | Profile with browser dev tools, reduce draw calls, use object pooling, and optimize asset sizes |
138+
| Touch controls are unresponsive | Prevent default touch behavior and handle touch events separately from mouse events |
139+
| WebGL context lost | Handle the `webglcontextlost` event and restore state on `webglcontextrestored` |

0 commit comments

Comments
 (0)