Hi all,
Back to ask another Delphi question.
Suppose i have four or more moving images on a form (panel or whatever) that are moving from the bottom of the form to the top, once they go off screen (cannot be seen anymore) they have their Top positions reset to a random value that is between the areas of the bottom most part of the form and some large number (that way the images appear at differing time intervals upon the visible part of the form), at the same time as their top positions are reset, they also have their Left property set a random value...
Now the trouble is, sometimes these images will overlap and one will be on top of the other!, i need some method of detecting this and then correcting it by assigning a new Top and Left property to the image/s
How is collision detection done with multiple images?.
two images are fine you just check
"if (image1.top <= image2.top +image2.height) and (image1.top >= image2.top) then"
and if these conditions are met you can simply execute
"image2.top := image1.top +(image1.height +10)"
but things get more complicated with multiple images, as you need to check the condition of each individual image and then when you change the Top and Left properties of one image you must recheck the values of all other images AGAIN to make sure that the new Top and Left values of the image you just moved do not collide with yet another image!.