game-engine
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.
What this skill does
# 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` |
Related in Image & Video
watch
IncludedWatch a video (URL or local path). Downloads with yt-dlp, extracts auto-scaled frames with ffmpeg, pulls the transcript from captions (or Whisper API fallback), and hands the result to Claude so it can answer questions about what's in the video.
physical-ai-defect-image-generation
IncludedUse when the user wants to orchestrate defect image generation, run associated setup, or handle outputs on OSMO. The Day 0 path handles cold-start with USD-to-ROI, image-edit augmentation, and AnomalyGen to create initial PCBA datasets. The Day 1 path performs inference and labeling on real images. This skill helps with first-time asset setup, creation of finetuning checkpoints, and configuring deployment. Trigger keywords: defect image generation, dig workflow, dig pipeline, defect image detection workflow, aoi pipeline, aoi anomalygen, usd2roi anomalygen, day 0 pcba, day 1 pcba, day 1 real-photo alignment, day 1 manual roi, metal surface anomaly, glass defect, anomalygen finetune, setup_pcb, setup_metal, setup_glass, setup_pretrained, dig setup, dig datasets, dig pretrained checkpoint, dig image-edit endpoint.
accelint-react-best-practices
IncludedReact performance optimization and best practices. ALWAYS use this skill when working with any React code - writing components, hooks, JSX; refactoring; optimizing re-renders, memoization, state management; reviewing for performance; fixing hydration mismatches; debugging infinite re-renders, stale closures, input focus loss, animations restarting; preventing remounting; implementing transitions, lazy initialization, effect dependencies. Even simple React tasks benefit from these patterns. Covers React 19+ (useEffectEvent, Activity, ref props). Triggers - useEffect, useState, useMemo, useCallback, memo, inline components, nested components, components inside components, re-render, performance, hydration, SSR, Next.js, useDeferredValue, combined hooks.
elevenlabs-agents
IncludedBuild conversational AI voice agents with ElevenLabs Platform using React, JavaScript, React Native, or Swift SDKs. Configure agents, tools (client/server/MCP), RAG knowledge bases, multi-voice, and Scribe real-time STT. Use when: building voice chat interfaces, implementing AI phone agents with Twilio, configuring agent workflows or tools, adding RAG knowledge bases, testing with CLI "agents as code", or troubleshooting deprecated @11labs packages, Android audio cutoff, CSP violations, dynamic variables, or WebRTC config. Keywords: ElevenLabs Agents, ElevenLabs voice agents, AI voice agents, conversational AI, @elevenlabs/react, @elevenlabs/client, @elevenlabs/react-native, @elevenlabs/elevenlabs-js, @elevenlabs/agents-cli, elevenlabs SDK, voice AI, TTS, text-to-speech, ASR, speech recognition, turn-taking model, WebRTC voice, WebSocket voice, ElevenLabs conversation, agent system prompt, agent tools, agent knowledge base, RAG voice agents, multi-voice agents, pronunciation dictionary, voice speed control, elevenlabs scribe, @11labs deprecated, Android audio cutoff, CSP violation elevenlabs, dynamic variables elevenlabs, case-sensitive tool names, webhook authentication
humanizer
IncludedHumanize AI-generated text by detecting and removing patterns typical of LLM output. Rewrites text to sound natural, specific, and human. Uses 28 pattern detectors, 560+ AI vocabulary terms across 3 tiers, and statistical analysis (burstiness, type-token ratio, readability) for comprehensive detection. Use when asked to humanize text, de-AI writing, make content sound more natural/human, review writing for AI patterns, score text for AI detection, or improve AI-generated drafts. Covers content, language, style, communication, and filler categories.
generating-mermaid-diagrams
IncludedSalesforce architecture diagrams using Mermaid with ASCII fallback. Use this skill when generating text-based diagrams for Salesforce architecture, OAuth flows, ERDs, integration sequences, or Agentforce structure. TRIGGER when: user says "diagram", "visualize", "ERD", or asks for sequence diagrams, flowcharts, class diagrams, or architecture visualizations in Mermaid. DO NOT TRIGGER when: user wants PNG/SVG image output (use generating-visual-diagrams), or asks about non-Salesforce systems.