Jump to content
  • Advertisement
Sign in to follow this  
raptorstrike

rand position set problem *solved*

This topic is 5027 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
Advertisement
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
Sign in to follow this  

  • Advertisement

Important Information

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

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!