Jump to content
  • Advertisement
Sign in to follow this  
jagguy

2D collison detection in directx confusion

This topic is 4400 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

Advertisement
Guest Anonymous Poster
As such, DirectX is a very low level API not recommended for beginners or even for experienced programmers looking to develop powerful games.

You should use DirectX to build a game engine/framework rather than a game itself. As there are many free high-level game libraries/toolkits available you should probably use one of those instead of DirectX.

Also take a look at SDL too. It's much easier for any game programmer to get into.

Share this post


Link to post
Share on other sites
I can do directx stuff and have no intention of using anything else.


I wanted to know about collision detection and what to do, otherwise I could be messing around for weeks.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Well, why reinvent the wheel? There are plenty of collision detection routines available.

If you want to roll your own, then probably you should implement something like this. A simple rectangular collision detection scheme.

Store each object you want on the screen with its attributes as a rectangle, x1, y1, x2, y2 etc. Then have a collide_detect () method in your class which takes another object as a parameter which checks the other object's rectangle and see if it intersects your object's rectangle.

That is whether:

Compare the obj1.x1 and obj2.x1 - this will determine which object is on the left and which on the right.

Compare the obj1.y1 and obj2.y1 - this will determine which object is on top and which is on the bottom.

Now you must check (based on left and right and top and bottom) whether the x2 of the left object is greater or equal to x1 of the right object and again whether the y2 of the top object is greater than or equal to the y1 of the bottom object.

That's all.

As to wanting to use DirectX, that's fine, but I wondered why you would want to reinvent the wheel especially with something as basic as collision detect and so suggested you use a higher levle game engine which already implements these features.

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!