Sign in to follow this  

rand position set problem *solved*

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

ok i have a position set function and im using rand for the x and y axis but there is no way to keep 2 images from loading on top of each other heres what i have so far for (int l = 0; l <30; l++) { blocks[l]->SetPosition(rand()%500, rand()%450); }; i dont really want to have to check its position with one block to every other block but the alternative is specifeing every were every block gose. Should i just use a tile setup to draw were i feed the array of 1s and 0s into a switch statement so that setting the positions would be quicker? thx [Edited by - raptorstrike on September 18, 2004 4:41:49 PM]

Share this post


Link to post
Share on other sites
You're best option is to do a bounding-box collision check when you set a random position to make sure there is nothing already where you want to put the image. If there is something there, get a new random position, then redo the collision check, etc.

Doing it this way will give you more flexibility than a grid-based system, and grids are a nightmare to set up if you've never done it before.


Mushu - trying to help those he doesn't know, with things he doesn't know.
Why won't he just go away? An question the universe may never have an answer to...

Share this post


Link to post
Share on other sites

This topic is 4834 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this