Jump to content
  • Advertisement
Sign in to follow this  
lazE

inheritance

This topic is 5042 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hey, I am trying to setup a collision detection scheme in my game right now. Basically I'll have one array of objects that move and objects that are stationary. All moving objects will check themselves against the stationary and mobile objects. The problem is that the mobile objects arent all of the same class type. I was wondering if class inheritance could solve this problem. Would I be able to have all of my objects (mobile or immobile) inherit from the same base class and have functions that do things like return the position and apply collision response run the correct code for what class they actually are? Sorry if I'm unclear...heh. Thanks.

Share this post


Link to post
Share on other sites
Advertisement
If you're going to have an array of all moving objects, then they'll have to have a common base type anyway.

Yes, inheritance and polymorphic dispatch would do the job. Lookup the virtual keyword.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!