Hands-On Game Development with WebAssembly
上QQ阅读APP看书,第一时间看更新

Collision Detection

Right now, our spaceships can fly around and shoot at each other, but nothing happens.

Collision detection is used in the vast majority of video games to determine whether game objects intersect. There are a large number of methods for detecting collisions between different game objects. Various methods can work better in different situations. There is also a trade-off between the amount of computation time and how accurate our collision detection will be. 

You will need to include several images in your build to make this project work. Make sure you include the /Chapter07/sprites/ folder from the project's GitHub. If you haven't yet downloaded the GitHub project, you can get it online here:  https://github.com/PacktPublishing/Hands-On-Game-Develop ment-with-WebAssembly.

In this chapter, we will discuss the following:

  • Collision detection
  • Collider objects
  • Types of colliders
  • Adding colliders to our game objects