Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Building your First Mobile Game using XNA 4.0

You're reading from   Building your First Mobile Game using XNA 4.0 A fast-paced, hands-on guide to building a 3D game for the Windows Phone 7 platform using XNA 4.0

Arrow left icon
Product type Paperback
Published in Jan 2013
Publisher Packt
ISBN-13 9781849687744
Length 158 pages
Edition 1st Edition
Languages
Arrow right icon
Authors (2):
Arrow left icon
Thomas Goussaert Thomas Goussaert
Author Profile Icon Thomas Goussaert
Thomas Goussaert
Brecht Kets Brecht Kets
Author Profile Icon Brecht Kets
Brecht Kets
Arrow right icon
View More author details
Toc

Collision


Now we will implement collision, and by collision we actually mean collision detection. We will detect whether two objects are currently colliding with each other. We can then create appropriate actions. Not that we will not actually implement the physical collision (for instance a car hitting the wall). If we want to do this, we should use a physics engine.

We will make a difference between 2D collision and 3D collision. When testing for collision of two 2D game objects, we use rectangles. This rectangle surrounds the object, and we can then check whether these rectangles intersect with each other. Note that if you have a cross for instance, the bounding rectangle will be too big for the object, but for our intended purposes, a rectangle will do just fine.

3D collision is very similar to 2D collision; the only difference is that we will use the BoundingBox class instead of the Rectangle class. All the steps are the same as with 2D collision, but we make use of 3D coordinates. This...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image