Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion .codespellrc
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,13 @@

# FillIn - pdftk-server skill reference file available permission

ignore-words-list = numer,wit,aks,edn,ser,ois,gir,rouge,categor,aline,ative,afterall,deques,dateA,dateB,TE,FillIn,alle,vai
# LOD - Level of Detail

# InOut - template property in skills/game-engine/assets/2d-platform-game.md

# pixelX - template variable in skill/game-engine/assets/simple-2d-engine.md

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

# Skip certain files and directories

Expand Down
1 change: 1 addition & 0 deletions docs/README.skills.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ Skills differ from other primitives by supporting bundled assets (scripts, code
| [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` |
| [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` |
| [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` |
| [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` |
| [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 |
| [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 |
| [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` |
Expand Down
139 changes: 139 additions & 0 deletions skills/game-engine/SKILL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
---
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

- 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-repo.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-principles.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` |
Loading