Randomly spawning bitmaps on cnvas

Posted by Toystoj on Game Development See other posts from Game Development or by Toystoj
Published on 2012-10-06T12:21:28Z Indexed on 2012/10/06 15:53 UTC
Read the original article Hit count: 217

I need some ideas in order to finish algorithm. I'm randomly placing objects (bitmaps) on canvas without overlapping. Time needed to finish it is my problem. When I need to spawn for example 80% of canvas it takes to long. So i was thinking : I should make some change when the bitmaps take off 50 % of canvas. I want to tell algorithm that it should generate new locations (x,y) where it is free space.

My question is : How to render new location (x,y) in place where is free space.

In summary:

Things I know :

  • object location (x,y)
  • 4 corners (x,y) of object
  • object width, height
  • canvas width, height

Any suggestions?

© Game Development or respective owner

Related posts about android

Related posts about collision-detection