Chapter 9. Physics

This chapter covers some basic physics features that will improve the capabilities of the game engine. We will explore two different ways to detect collisions between entities. Real games have sprites that interact, with bullets and missiles that hit enemy ships and cause them to explode, sprites that must navigate a maze without going through walls, and sprites that can run and jump over crates and land on top of enemy characters (such as how Mario jumps onto turtles in Super Mario World to knock them out). All of these situations require the ability to detect when two sprites have collided, or touched each other. Sprite collision opens up the world of game programming and makes it possible for you to build a real game! The key to collision testing is to identify where two sprites are on the screen, and then compare their bounding rectangles. That is why this type of collision testing is called bounding rectangle collision detection. We will also consider circular collision based on the distance between two entities.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset