Jump to content
  • Advertisement
Sign in to follow this  
blueshogun96

Generating shapes?

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

Hi. I'm creating an asteroids clone similar to this one here: http://www.0catch.com/games/asteroids/. I was hoping that someone could point me in the right direction as to how to generate some asteroids with random shapes. I'd rather not use the same shape over and over again, because that would make my game have more of a static feel to it. Btw, how would I do my collision detection for each shape? I'm used to using the bounding box? Should I create a small bounding box for each shot from the ship and test for a collision with each line of the asteroid? Thanks.

Share this post


Link to post
Share on other sites
Advertisement
One way to generate some shapes would be to create polygons where the radius of each vertex from some center is randomized. Essentially, you are "trying" to create a circle (if you keep the radii the same) with a handful of points. So a three sided circle is an equilateral triangle, four is a square, and so forth. If you randomize the radius you can get some nice looking shapes.

As for collision detection, you could go about it a couple ways. If you want to keep all your asteroids convex (probably not, though) you could do a simple test that checks to see if a vertex from another shape is inside your asteroid and use this to check it against all vertices that fall within the bounding box.

For non-convex shapes, you could either use line intersection tests
A great intersection method

or you could write an algorithm to break each shape into convex regions and use the first method I described. If you use the method I offered for creating your polygons, you will inevitably make non-convex shapes.

Let me know if you would like me to describe something in more detail.

Share this post


Link to post
Share on other sites
If asteroids aren't massive compared to the player ship you might get away with using distance (i.e. circle) based collision

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!