kb/data/developer.mozilla.org/en-US/docs/Games/Techniques-0.md

209 lines
14 KiB
Markdown

---
title: "Techniques for game development - Game development | MDN"
chunk: 1/2
source: "https://developer.mozilla.org/en-US/docs/Games/Techniques"
category: "reference"
tags: "web, html, css, javascript, documentation"
date_saved: "2026-05-05T05:21:04.390633+00:00"
instance: "kb-cron"
---
* [Skip to main content](https://developer.mozilla.org/en-US/docs/Games/Techniques#content)
* [Skip to search](https://developer.mozilla.org/en-US/docs/Games/Techniques#search)
[ MDN ](https://developer.mozilla.org/en-US/)
HTML
[HTML: Markup language](https://developer.mozilla.org/en-US/docs/Web/HTML)
HTML reference
* [Elements](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements)
* [Global attributes](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Global_attributes)
* [Attributes](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Attributes)
* [See all…](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference "See all HTML references")
HTML guides
* [Responsive images](https://developer.mozilla.org/en-US/docs/Web/HTML/Guides/Responsive_images)
* [HTML cheatsheet](https://developer.mozilla.org/en-US/docs/Web/HTML/Guides/Cheatsheet)
* [Date & time formats](https://developer.mozilla.org/en-US/docs/Web/HTML/Guides/Date_and_time_formats)
* [See all…](https://developer.mozilla.org/en-US/docs/Web/HTML/Guides "See all HTML guides")
Markup languages
* [SVG](https://developer.mozilla.org/en-US/docs/Web/SVG)
* [MathML](https://developer.mozilla.org/en-US/docs/Web/MathML)
* [XML](https://developer.mozilla.org/en-US/docs/Web/XML)
CSS
[CSS: Styling language](https://developer.mozilla.org/en-US/docs/Web/CSS)
CSS reference
* [Properties](https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Properties)
* [Selectors](https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Selectors)
* [At-rules](https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/At-rules)
* [Values](https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Values)
* [See all…](https://developer.mozilla.org/en-US/docs/Web/CSS/Reference "See all CSS references")
CSS guides
* [Box model](https://developer.mozilla.org/en-US/docs/Web/CSS/Guides/Box_model/Introduction)
* [Animations](https://developer.mozilla.org/en-US/docs/Web/CSS/Guides/Animations/Using)
* [Flexbox](https://developer.mozilla.org/en-US/docs/Web/CSS/Guides/Flexible_box_layout/Basic_concepts)
* [Colors](https://developer.mozilla.org/en-US/docs/Web/CSS/Guides/Colors/Applying_color)
* [See all…](https://developer.mozilla.org/en-US/docs/Web/CSS/Guides "See all CSS guides")
Layout cookbook
* [Column layouts](https://developer.mozilla.org/en-US/docs/Web/CSS/How_to/Layout_cookbook/Column_layouts)
* [Centering an element](https://developer.mozilla.org/en-US/docs/Web/CSS/How_to/Layout_cookbook/Center_an_element)
* [Card component](https://developer.mozilla.org/en-US/docs/Web/CSS/How_to/Layout_cookbook/Card)
* [See all…](https://developer.mozilla.org/en-US/docs/Web/CSS/How_to/Layout_cookbook)
JavaScriptJS
[JavaScript: Scripting language](https://developer.mozilla.org/en-US/docs/Web/JavaScript)
JS reference
* [Standard built-in objects](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects)
* [Expressions & operators](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators)
* [Statements & declarations](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements)
* [Functions](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions)
* [See all…](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference "See all JavaScript references")
JS guides
* [Control flow & error handing](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Control_flow_and_error_handling)
* [Loops and iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Loops_and_iteration)
* [Working with objects](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Working_with_objects)
* [Using classes](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Using_classes)
* [See all…](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide "See all JavaScript guides")
Web APIs
[Web APIs: Programming interfaces](https://developer.mozilla.org/en-US/docs/Web/API)
Web API reference
* [File system API](https://developer.mozilla.org/en-US/docs/Web/API/File_System_API)
* [Fetch API](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API)
* [Geolocation API](https://developer.mozilla.org/en-US/docs/Web/API/Geolocation_API)
* [HTML DOM API](https://developer.mozilla.org/en-US/docs/Web/API/HTML_DOM_API)
* [Push API](https://developer.mozilla.org/en-US/docs/Web/API/Push_API)
* [Service worker API](https://developer.mozilla.org/en-US/docs/Web/API/Service_Worker_API)
* [See all…](https://developer.mozilla.org/en-US/docs/Web/API "See all Web API guides")
Web API guides
* [Using the Web animation API](https://developer.mozilla.org/en-US/docs/Web/API/Web_Animations_API/Using_the_Web_Animations_API)
* [Using the Fetch API](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch)
* [Working with the History API](https://developer.mozilla.org/en-US/docs/Web/API/History_API/Working_with_the_History_API)
* [Using the Web speech API](https://developer.mozilla.org/en-US/docs/Web/API/Web_Speech_API/Using_the_Web_Speech_API)
* [Using web workers](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Using_web_workers)
All
[All web technology](https://developer.mozilla.org/en-US/docs/Web)
Technologies
* [Accessibility](https://developer.mozilla.org/en-US/docs/Web/Accessibility)
* [HTTP](https://developer.mozilla.org/en-US/docs/Web/HTTP)
* [URI](https://developer.mozilla.org/en-US/docs/Web/URI)
* [Web extensions](https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions)
* [WebAssembly](https://developer.mozilla.org/en-US/docs/WebAssembly)
* [WebDriver](https://developer.mozilla.org/en-US/docs/Web/WebDriver)
* [See all…](https://developer.mozilla.org/en-US/docs/Web "See all web technology references")
Topics
* [Media](https://developer.mozilla.org/en-US/docs/Web/Media)
* [Performance](https://developer.mozilla.org/en-US/docs/Web/Performance)
* [Privacy](https://developer.mozilla.org/en-US/docs/Web/Privacy)
* [Security](https://developer.mozilla.org/en-US/docs/Web/Security)
* [Progressive web apps](https://developer.mozilla.org/en-US/docs/Web/Progressive_web_apps)
Learn
[Learn web development](https://developer.mozilla.org/en-US/docs/Learn_web_development)
Frontend developer course
* [Getting started modules](https://developer.mozilla.org/en-US/docs/Learn_web_development/Getting_started)
* [Core modules](https://developer.mozilla.org/en-US/docs/Learn_web_development/Core)
* [MDN Curriculum](https://developer.mozilla.org/en-US/curriculum/)
* [Check out the video course from Scrimba, our partner](https://scrimba.com/frontend-path-c0j?via=mdn-learn-navbar)
Learn HTML
* [Structuring content with HTML module](https://developer.mozilla.org/en-US/docs/Learn_web_development/Core/Structuring_content)
Learn CSS
* [CSS styling basics module](https://developer.mozilla.org/en-US/docs/Learn_web_development/Core/Styling_basics)
* [CSS layout module](https://developer.mozilla.org/en-US/docs/Learn_web_development/Core/CSS_layout)
Learn JavaScript
* [Dynamic scripting with JavaScript module](https://developer.mozilla.org/en-US/docs/Learn_web_development/Core/Scripting)
Tools
Discover our tools
* [Playground](https://developer.mozilla.org/en-US/play)
* [HTTP Observatory](https://developer.mozilla.org/en-US/observatory)
* [Border-image generator](https://developer.mozilla.org/en-US/docs/Web/CSS/Guides/Backgrounds_and_borders/Border-image_generator)
* [Border-radius generator](https://developer.mozilla.org/en-US/docs/Web/CSS/Guides/Backgrounds_and_borders/Border-radius_generator)
* [Box-shadow generator](https://developer.mozilla.org/en-US/docs/Web/CSS/Guides/Backgrounds_and_borders/Box-shadow_generator)
* [Color format converter](https://developer.mozilla.org/en-US/docs/Web/CSS/Guides/Colors/Color_format_converter)
* [Color mixer](https://developer.mozilla.org/en-US/docs/Web/CSS/Guides/Colors/Color_mixer)
* [Shape generator](https://developer.mozilla.org/en-US/docs/Web/CSS/Guides/Shapes/Shape_generator)
About
Get to know MDN better
* [About MDN](https://developer.mozilla.org/en-US/about)
* [Advertise with us](https://developer.mozilla.org/en-US/advertising)
* [Community](https://developer.mozilla.org/en-US/community)
* [MDN on GitHub](https://github.com/mdn)
[Blog](https://developer.mozilla.org/en-US/blog/)
1. [Game development](https://developer.mozilla.org/en-US/docs/Games)
2. [Techniques for game development](https://developer.mozilla.org/en-US/docs/Games/Techniques)
# Techniques for game development
This page lists essential core techniques for anyone wanting to develop games using open web technologies.
[2D collision detection](https://developer.mozilla.org/en-US/docs/Games/Techniques/2D_collision_detection)
Algorithms to detect collision in 2D games depend on the type of shapes that can collide (e.g., Rectangle to Rectangle, Rectangle to Circle, Circle to Circle). Generally you will have a simple generic shape that covers the entity known as a "hitbox" so even though collision may not be pixel perfect, it will look good enough and be performant across multiple entities. This article provides a review of the most common techniques used to provide collision detection in 2D games.
[3D collision detection](https://developer.mozilla.org/en-US/docs/Games/Techniques/3D_collision_detection)
This article provides an introduction to the different bounding volume techniques used to implement collision detection in 3D environments. Followup articles will cover implementations in specific 3D libraries.
[3D games on the Web](https://developer.mozilla.org/en-US/docs/Games/Techniques/3D_on_the_web)
For rich gaming experiences on the web, the weapon of choice is WebGL, which is rendered on HTML `canvas`. WebGL is basically an OpenGL ES 2.0 for the Web — it's a JavaScript API providing tools to build rich interactive animations and of course, also games. You can generate and render dynamic 3D graphics with JavaScript that is hardware accelerated.
[Async scripts for asm.js](https://developer.mozilla.org/en-US/docs/Games/Techniques/Async_scripts)
Every medium or large game should compile [asm.js](https://developer.mozilla.org/en-US/docs/Games/Tools/asm.js) code as part of an async script to give the browser the maximum flexibility to optimize the compilation process. In Gecko, async compilation allows the JavaScript engine to compile the asm.js off the main thread when the game is loading and cache the generated machine code so that the game doesn't need to be compiled on subsequent loads (starting in Firefox 28). To see the difference, toggle `javascript.options.parallel_parsing` in `about:config`.
[Audio for Web games](https://developer.mozilla.org/en-US/docs/Games/Techniques/Audio_for_Web_Games)
Audio is an important part of any game; it adds feedback and atmosphere. Web-based audio is maturing fast, but there are still many browser differences to navigate. We often need to decide which audio parts are essential to our games' experience and which are nice to have but not essential, and devise a strategy accordingly. This article provides a detailed guide to implementing audio for web games, looking at what works currently across as wide a range of platforms as possible.
[Crisp pixel art look with image-rendering](https://developer.mozilla.org/en-US/docs/Games/Techniques/Crisp_pixel_art_look)
This article discusses a useful technique for giving your canvas/WebGL games a crisp pixel art look, even on high definition monitors.
[Implementing controls using the Gamepad API](https://developer.mozilla.org/en-US/docs/Games/Techniques/Controls_Gamepad_API)
This article looks at implementing an effective, cross-browser control system for web games using the Gamepad API, allowing you to control your web games using console game controllers. It features a case study game — Hungry Fridge, created by [Enclave Games](https://enclavegames.com/).
[Implementing game control mechanisms](https://developer.mozilla.org/en-US/docs/Games/Techniques/Control_mechanisms)
One of HTML5's main advantages as a game development platform is the ability to run on various platforms and devices. Streamlining cross device differences creates multiple challenges, not least when providing appropriate controls for different contexts. In this series of articles we will show you how you can approach building a game that can be played using touchscreen smartphones, mouse and keyboard, and also less common mechanisms such as gamepads.
[Tiles and tilemaps overview](https://developer.mozilla.org/en-US/docs/Games/Techniques/Tilemaps)
Tilemaps are a very popular technique in 2D game development, consisting of building the game world or level map out of small, regular-shaped images called **tiles**. This results in performance and memory usage gains — big image files containing entire level maps are not needed, as they are constructed by small images or image fragments multiple times. This set of articles covers the basics of creating tile maps using [JavaScript](https://developer.mozilla.org/en-US/docs/Web/JavaScript) and [Canvas](https://developer.mozilla.org/en-US/docs/Web/API/Canvas_API) (although the same high level techniques could be used in any programming language.)