Search icon CANCEL
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
OpenGL Game Development By Example

You're reading from   OpenGL Game Development By Example Design and code your own 2D and 3D games efficiently using OpenGL and C++

Arrow left icon
Product type Paperback
Published in Mar 2016
Publisher
ISBN-13 9781783288199
Length 340 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Authors (2):
Arrow left icon
Robert Madsen Robert Madsen
Author Profile Icon Robert Madsen
Robert Madsen
Stephen Madsen Stephen Madsen
Author Profile Icon Stephen Madsen
Stephen Madsen
Arrow right icon
View More author details
Toc

Table of Contents (14) Chapters Close

Collideables

There are many times that we may want to check and see whether objects in the game have collided with each other. We may want to see whether the player has struck an obstacle or an enemy. We may have objects that the player can pick up, often called pickups or powerups.

Collectively, objects in the game that can collide with other objects are known as collideables. When we created our Sprite class, we actually it designed for this. Looking at the class constructor, you will notice that member variable m_isCollideable is set to false. When we write our collision detection code, we will ignore objects that have m_isCollideable set to false. If we want to allow an object to collide with other objects, we have to make sure to set m_collideable to true.

Ready to score

To keep our design simple, we are going to create one enemy and one pickup. Running into an enemy will subtract points from the player's score, while running into the pickup will increase the player's score...

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 €18.99/month. Cancel anytime