There are two main ways that you can check for collisions in games. The first is to compare the x and y pixel positions of sprites on the screen. If their shapes are overlapping, you have a collision. This is a collision detection strategy called narrow-phase collision. If you’ve used a game engine with collision functions that might have names like hitTestRectangle or hitTestCircle to check whether shapes are overlapping, it’s likely that these are narrow-phase collision functions. They use vector math (linear algebra) to figure out if the shapes of the sprites are overlapping. ...
© Rex van der Spuy 2017
Rex van der Spuy, The Advanced Game Developer's Toolkit, 10.1007/978-1-4842-1097-0_3
3. Tile-Based Collision
Rex van der Spuy1
(1)Toronto, Ontario, Canada
Get The Advanced Game Developer's Toolkit: Create Amazing Web-based Games with JavaScript and HTML5 now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.