Game Engine
GitHubOfficialFirst committed by jhaugaDistributed by GitHub
- Skill
- Tool integration
- Software development
- MIT
- No issues found
AutoGineer summary
Written by AutoGineer from the skill’s own files, not by the author
The Game Engine skill provides a structured approach to developing interactive 2D and 3D games for the web. It covers the entire lifecycle of game development, from core engine architecture—such as the game loop and rendering pipelines—to specific implementations of physics, collision detection, and input handling. The skill includes reference documentation on web APIs, algorithms, and 3D theory, alongside practical templates for common game types like platformers and maze games.
What it does
- Provides workflows for building game engines and games from scratch.
- Explains core concepts like game loops, rendering, and physics.
- Offers reference material for WebGL, Canvas, and Web Audio APIs.
- Includes starter templates for 2D platformers and breakout-style games.
- Covers advanced topics like raycasting, collision detection, and multiplayer networking.
- Guides users through asset optimization and game publishing.
When to use it
- When you need to build a web-based game or a custom game engine.
- When implementing game mechanics like physics, collision, or input controls.
- When you need to understand 3D rendering pipelines or WebGL fundamentals.
- When you are looking for starter code for 2D or 3D web game projects.
- When you need to optimize game performance or handle cross-browser audio issues.
Advantages
- Centralizes essential game development knowledge for the web.
- Provides ready-to-use templates to accelerate project setup.
- Offers clear, step-by-step procedures for common game development tasks.
- Includes troubleshooting guides for common rendering and performance issues.
- Supports both 2D (Canvas) and 3D (WebGL/Three.js) development workflows.
Usage examples
- “How do I set up a basic game loop using requestAnimationFrame?”
- The agent provides a code structure that initializes a canvas, defines an update function for game logic, and a render function for drawing, tied together by a recursive requestAnimationFrame call.
- “Can you help me implement AABB collision detection for my 2D platformer?”
- The agent explains the Axis-Aligned Bounding Box algorithm and provides a JavaScript function to check if two rectangular objects overlap.
- “What are the steps to publish my web game?”
- The agent outlines a checklist including asset compression, code minification, cross-browser testing, and choosing a distribution platform.
Install
Download the skill as a ZIP:
https://autogineer.com/agent-skills/github/game-engine/downloadUnzip it into the cross-client skills folder of your project:
mkdir -p .agents/skills && unzip game-engine.zip -d .agents/skills
Documentation by jhauga
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:
Process Input - Read keyboard, mouse, touch, or gamepad input
Update State - Update game object positions, physics, AI, and logic
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
Set up an HTML file with a
<canvas>elementGet the 2D rendering context
Implement the game loop using
requestAnimationFrameCreate game objects with position, velocity, and size properties
Handle keyboard/mouse input for player control
Implement collision detection between game objects
Add scoring, lives, and win/lose conditions
Add sound effects and music
Building a 3D Game
Choose a framework (Three.js, Babylon.js, A-Frame, or PlayCanvas)
Set up the scene, camera, and renderer
Load or create 3D models and textures
Implement lighting and shaders
Add physics and collision detection
Implement player controls and camera movement
Add audio and visual effects
Publishing a Game
Optimize assets (compress images, minify code)
Test across browsers and devices
Choose distribution platform (web, app stores, game portals)
Implement monetization if needed
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 |
Files
- ATTRIBUTION.mdAdded by AutoGineer851 B
- LICENSELicence file added by AutoGineer1.0 KiB
- SKILL.md6.2 KiB
- assets/2d-maze-game.md13.0 KiB
- assets/2d-platform-game.md58.2 KiB
- assets/gameBase-template-repo.md9.9 KiB
- assets/paddle-game-template.md38.4 KiB
- assets/simple-2d-engine.md14.0 KiB
- references/3d-web-games.md23.9 KiB
- references/algorithms.md24.5 KiB
- references/basics.md10.9 KiB
- references/game-control-mechanisms.md19.1 KiB
- references/game-engine-core-principles.md21.6 KiB
- references/game-publishing.md13.7 KiB
- references/techniques.md27.4 KiB
- references/terminology.md19.4 KiB
- references/web-apis.md51.4 KiB
references/basics.md
Game Development Basics
A comprehensive reference covering web game development technologies, game architecture, and the anatomy of a game loop.
Sources:
Web Technologies for Game Development
Graphics and Rendering
WebGL -- Hardware-accelerated 2D and 3D graphics based on OpenGL ES 2.0. Provides direct GPU access for high-performance rendering.
Canvas API -- 2D drawing surface via the
<canvas>element. Suitable for 2D games, sprite rendering, and pixel manipulation.SVG -- Scalable Vector Graphics for resolution-independent visuals. Useful for UI elements and simple vector-based games.
HTML/CSS -- Standard web technologies for building game UI, menus, HUDs, and overlays.
Audio
Web Audio API -- Advanced audio engine supporting real-time playback, synthesis, spatial audio, effects processing, and dynamic mixing.
HTML Audio Element -- Simple sound playback for background music and basic sound effects.
Input and Controls
Gamepad API -- Support for game controllers and gamepads, including button mapping and analog stick input.
Touch Events API -- Multi-touch input handling for mobile devices.
Pointer Lock API -- Locks the mouse cursor within the game area and provides raw coordinate deltas for precise camera/aiming control.
Device Sensors -- Accelerometer and gyroscope access for motion-based input.
Full Screen API -- Enables immersive full-screen game experiences.
Networking and Multiplayer
WebSockets API -- Persistent, bidirectional communication channel for real-time multiplayer, chat, and live updates.
WebRTC API -- Peer-to-peer connections for low-latency multiplayer, voice chat, and data channels.
Fetch API -- HTTP requests for downloading game assets, loading level data, and transmitting non-real-time game state.
Data Storage and Performance
IndexedDB API -- Client-side structured storage for save games, cached assets, and offline play support.
Typed Arrays -- Direct access to raw binary data buffers for GL textures, audio samples, and compact game data.
Web Workers API -- Background thread execution for offloading heavy computations (physics, pathfinding, AI) without blocking the main thread.
Languages and Compilation
JavaScript -- The primary language for web game development.
C/C++ via Emscripten -- Compile existing native game code to JavaScript or WebAssembly for web deployment.
WebAssembly (Wasm) -- Near-native execution speed for performance-critical game code.
Types of Games You Can Build
The modern web platform supports a full range of game types:
3D action games and shooters
Role-playing games (RPGs)
2D platformers and side-scrollers
Puzzle and strategy games
Card and board games
Casual and mobile-friendly games
Multiplayer experiences with real-time networking
Advantages of Web-Based Game Development
Universal reach -- Games run on smartphones, tablets, PCs, and Smart TVs through the browser.
No app store dependency -- Deploy directly on the web without store approval processes.
Full revenue control -- No mandatory revenue share; use any payment processing system.
Instant updates -- Push updates immediately without waiting for store review.
Own your analytics -- Collect your own data or choose any analytics provider.
Direct player relationships -- Engage players without intermediaries.
Inherent shareability -- Games are linkable and discoverable via standard web mechanisms.
Anatomy of a Game Loop
Every game operates through a continuous cycle of steps:
Present -- Display the current game state to the player.
Accept -- Receive user input (keyboard, mouse, gamepad, touch).
Interpret -- Process raw input into meaningful game actions.
Calculate -- Update the game state based on actions, physics, AI, and time.
Repeat -- Loop back to present the updated state.
Games may be event-driven (turn-based, waiting for player action) or per-frame (continuously updating via a main loop).
Building a Game Loop with requestAnimationFrame
Basic Main Loop
window.main = () => {
window.requestAnimationFrame(main);
// Your game logic here: update state, render frame
};
main(); // Start the cycleKey points:
requestAnimationFrame()synchronizes callbacks to the browser's repaint schedule (typically 60 Hz).Schedule the next frame before performing loop work to maximize available computation time.
Self-Contained Main Loop (IIFE)
;(() => {
function main() {
window.requestAnimationFrame(main);
// Game logic here
}
main();
})();Stoppable Main Loop
;(() => {
function main() {
MyGame.stopMain = window.requestAnimationFrame(main);
// Game logic here
}
main();
})();
// To stop the loop:
window.cancelAnimationFrame(MyGame.stopMain);Timing and Frame Rate
DOMHighResTimeStamp
requestAnimationFrame passes a DOMHighResTimeStamp to your callback, providing timing precision to 1/1000th of a millisecond.
;(() => {
function main(tFrame) {
MyGame.stopMain = window.requestAnimationFrame(main);
// tFrame is a high-resolution timestamp in milliseconds
// Use it for delta-time calculations
}
main();
})();Frame Time Budget
At 60 Hz, each frame has approximately 16.67ms of available processing time. The browser's frame cycle is:
Start new frame (previous frame displayed to screen)
Execute
requestAnimationFramecallbacksPerform garbage collection and per-frame browser tasks
Sleep until VSync, then repeat
Simple Update and Render Pattern
The simplest approach when your game can sustain the target frame rate:
;(() => {
function main(tFrame) {
MyGame.stopMain = window.requestAnimationFrame(main);
update(tFrame); // Process game logic
render(); // Draw the frame
}
main();
})();Assumptions:
Each frame can process input and update state within the time budget.
The simulation runs at the same rate as the display refresh (typically ~60 FPS).
No frame interpolation is needed.
Decoupled Update and Render with Fixed Timestep
For robust handling of variable refresh rates and consistent simulation behavior:
;(() => {
function main(tFrame) {
MyGame.stopMain = window.requestAnimationFrame(main);
const nextTick = MyGame.lastTick + MyGame.tickLength;
let numTicks = 0;
// Calculate how many simulation updates are needed
if (tFrame > nextTick) {
const timeSinceTick = tFrame - MyGame.lastTick;
numTicks = Math.floor(timeSinceTick / MyGame.tickLength);
}
queueUpdates(numTicks);
render(tFrame);
MyGame.lastRender = tFrame;
}
function queueUpdates(numTicks) {
for (let i = 0; i < numTicks; i++) {
MyGame.lastTick += MyGame.tickLength;
update(MyGame.lastTick);
}
}
MyGame.lastTick = performance.now();
MyGame.lastRender = MyGame.lastTick;
MyGame.tickLength = 50; // 20 Hz simulation rate (50ms per tick)
setInitialState();
main(performance.now());
})();Benefits:
Deterministic simulation -- Game logic runs at a fixed frequency regardless of display refresh rate.
Smooth rendering -- Rendering can interpolate between simulation states for visual smoothness.
Portable behavior -- Game behaves the same on 60 Hz, 120 Hz, and 144 Hz displays.
Alternative Architecture Patterns
Separate setInterval for Updates
// Game logic updates at a fixed rate
setInterval(() => {
update();
}, 50); // 20 Hz
// Rendering synchronized to display
requestAnimationFrame(function render(tFrame) {
requestAnimationFrame(render);
draw();
});Drawback: setInterval continues running even when the tab is not visible, wasting resources.
Web Worker for Updates
// Heavy game logic runs in a background thread
const updateWorker = new Worker('game-update-worker.js');
requestAnimationFrame(function render(tFrame) {
requestAnimationFrame(render);
updateWorker.postMessage({ ticks: numTicksNeeded });
draw();
});Benefits: Does not block the main thread. Ideal for physics-heavy or AI-intensive games. Drawback: Communication overhead between worker and main thread.
requestAnimationFrame Driving a Web Worker
;(() => {
function main(tFrame) {
MyGame.stopMain = window.requestAnimationFrame(main);
// Signal worker to compute updates
updateWorker.postMessage({
lastTick: MyGame.lastTick,
numTicks: calculatedNumTicks
});
render(tFrame);
}
main();
})();Benefits: No reliance on legacy timers. Worker performs computation in parallel.
Handling Tab Focus Loss
When a browser tab loses focus, requestAnimationFrame slows down or stops entirely. Strategies:
| Strategy | Description | Best For |
|---|---|---|
| Treat gap as pause | Skip elapsed time; do not update | Single-player games |
| Simulate the gap | Run all missed updates on regain | Simple simulations |
| Sync from server/peer | Fetch authoritative state | Multiplayer games |
Monitor the numTicks value after a focus-regain event. A very large value indicates the game was suspended and may need special handling rather than trying to simulate all missed frames.
Comparison of Timing Approaches
| Approach | Pros | Cons |
|---|---|---|
| Simple update/render per frame | Easy to implement, responsive | Breaks on slow/fast hardware |
| Fixed timestep + interpolation | Consistent simulation, smooth visuals | More complex to implement |
| Quality scaling | Maintains frame rate dynamically | Requires adaptive quality systems |
Performance Best Practices
Detach non-frame-critical code from the main loop. Use events and callbacks for UI, network responses, and other asynchronous operations.
Use Web Workers for computationally expensive tasks like physics, pathfinding, and AI.
Leverage GPU acceleration through WebGL for rendering.
Stay within the frame budget -- monitor your update + render time to keep it under 16.67ms for 60 FPS.
Throttle garbage collection pressure by reusing objects and avoiding per-frame allocations.
Plan your timing strategy early -- changing the game loop architecture mid-development is difficult and error-prone.
Popular 3D Frameworks and Libraries
Three.js -- General-purpose 3D library with a large ecosystem.
Babylon.js -- Full-featured 3D game engine with physics, audio, and scene management.
A-Frame -- Declarative 3D/VR framework built on Three.js.
PlayCanvas -- Cloud-hosted 3D game engine with a visual editor.
Phaser -- Popular 2D game framework with physics and input handling.
Requirements and compatibility
Written for: GitHub Copilot
Works with: Claude Code, Claude apps, OpenAI Codex, GitHub Copilot, Cursor, Gemini CLI, Kiro, OpenCode, Goose, Amp, Roo Code, JetBrains Junie, Factory Droid, Devin (ex-Windsurf), Mistral Vibe, OpenHands, Letta
“Works with” means the tool reads the open Agent Skills format; a skill written for one tool may use features others lack.
Security
No issues found by our static scan· No issues found
A static scan is not a guarantee. Skills are third-party content: review a skill before you let an agent use it.
Attribution and licence
- First committed by
jhauga
- Publisher
- GitHub (Official)
- Distributed by
- GitHub
- Source
- github/awesome-copilot · skills/game-engine · commit 797337f
- Licence
- MIT License (redistribution allowed)
- LICENSE (added by AutoGineer from LICENSE)
- ATTRIBUTION.md (written by AutoGineer)
- Synced
- Contributors
- jhauga
AutoGineer is not affiliated with or endorsed by jhauga or GitHub.
Download ZIP
The ZIP holds the skill’s files, its licence files and an ATTRIBUTION.md. Download game-engine.zip