2D collision detection - Game development - MDN Web Docs
文章推薦指數: 80 %
One of the simpler forms of collision detection is between two rectangles that are axis aligned — meaning no rotation. The algorithm works by ...
SkiptomaincontentSkiptosearchSkiptoselectlanguageGamedevelopmentTechniquesforgamedevelopment2DcollisiondetectionArticleActionsEnglish(US)Axis-AlignedBoundingBoxCircleCollisionSeparatingAxisTheoremCollisionPerformanceRelatedTopics
Introduction
Introduction
Anatomy
Examples
APIsforgamedevelopment
Canvas
CSS
Fullscreen
Gamepad
IndexedDB
JavaScript
PointerLock
SVG
TypedArrays
WebAudio
WebGL
WebRTC
WebSockets
WebVR
WebWorkers
XMLHttpRequest
Techniques
Usingasyncscriptsforasm.js
Optimizingstartupperformance
UsingWebRTCpeer-to-peerdatachannels
Efficientanimationforwebgames
AudioforWebGames
2Dcollisiondetection
Tilesandtilemapsoverview
3DgamesontheWeb
3DgamesontheWeboverview
Explainingbasic3Dtheory
BuildingupabasicdemowithA-Frame
BuildingupabasicdemowithBabylon.js
BuildingupabasicdemowithPlayCanvas
BuildingupabasicdemowithThree.js
WebVR
3Dcollisiondetection
BoundingvolumecollisiondetectionwithTHREE.js
Implementinggamecontrolmechanisms
Controlmechanisms
Mobiletouch
Desktopwithmouseandkeyboard
Desktopwithgamepad
Other
Tutorials
2DbreakoutgameusingpureJavaScript
2DbreakoutgameusingPhaser
2Dmaze_gamewithdeviceorientation
2DplatformgameusingPhaser
Publishinggames
Publishinggamesoverview
Gamedistribution
Gamepromotion
Gamemonetization
Axis-AlignedBoundingBoxCircleCollisionSeparatingAxisTheoremCollisionPerformance2DcollisiondetectionAlgorithmstodetectcollisionin2Dgamesdependonthetypeofshapesthatcancollide(e.g.RectangletoRectangle,RectangletoCircle,CircletoCircle).Generallyyouwillhaveasimplegenericshapethatcoverstheentityknownasa"hitbox"soeventhoughcollisionmaynotbepixelperfect,itwilllookgoodenoughandbeperformantacrossmultipleentities.Thisarticleprovidesareviewofthemostcommontechniquesusedtoprovidecollisiondetectionin2Dgames.Axis-AlignedBoundingBoxOneofthesimplerformsofcollisiondetectionisbetweentworectanglesthatareaxisaligned—meaningnorotation.Thealgorithmworksbyensuringthereisnogapbetweenanyofthe4sidesoftherectangles.Anygapmeansacollisiondoesnotexist.
Movetherectanglewitharrowkeys.Greenmeanscollision,bluemeansnocollision. Movethecirclewitharrowkeys.Greenmeanscollision,bluemeansnocollision.
延伸文章資訊
- 1Collision detection - LearnOpenGL
Because the ball is a circle-like object, an AABB is probably not the best choice for the ball's ...
- 22D collision detection - Game development - MDN Web Docs
One of the simpler forms of collision detection is between two rectangles that are axis aligned —...
- 3What is AABB - Collision detection? - Stack Overflow
AABB stands for "Axis-Aligned Bounding Box." It is a fairly computationally- and memory-efficient...
- 4Using Swept AABB to detect and process collision
AABB stands for Axis-Aligned Bounding Box, it is an algorithm to detect collision between a recta...
- 5Simple AABB vs AABB collision detection - Studio Freya
What is AABB? An AABB is an axis aligned bounding box. AABB vs AABB is a box vs box or bounding b...