Computer Science Canada Stop pictures from drawing on top of each other |
Author: | Flawedspirit [ Tue Dec 09, 2008 1:01 pm ] | ||
Post subject: | Stop pictures from drawing on top of each other | ||
Note: Download the pictures too for this to work. Anyway, the code below is supposed to draw the skeletons in random places on the screen, but how do I stop it from drawing a sprite on top of another sprite? Hopefully without 300 lines worth of if statements.
|
Author: | Tony [ Tue Dec 09, 2008 1:12 pm ] | ||
Post subject: | RE:Stop pictures from drawing on top of each other | ||
If you know the position of one image, and the position of another image, how far away must they be from each other so that they don't touch? also... this seems redundant
a single reference to the image file will do. |
Author: | Insectoid [ Tue Dec 09, 2008 4:14 pm ] |
Post subject: | RE:Stop pictures from drawing on top of each other |
Yes, 1 picture will suffice. Multiple sprites can have the same picture. You could use a for loop to count through the coordinates of previous sprites, and if it is within a certain distance of one, re-randomize. Continue until there are no overlapping pictures. |