What is a good way to generate 2D asteroids (top down) that don’t overlap with each other? If you can provide code in any language similar to C# or JAVA I’d be thankful.
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
I believe what you’re looking for is
2D Collision Detection. Here’s a good article about it with working sample code.EDIT: Based on what you’ve described, if you had each asteroid represented as a Rectangle, then you could simply check for Intersection:
Obviously this isn’t perfect since there could be corners that should be allowed to overlap, but it would be a fairly quick way of generating what you’d want (depending on how many asteroids you wanted to place).
EDIT 2: If you just want the code that checks for rectangular overlap, it can be found here.