image - refering to many objects under one name vb.net -


i'm trying make frogger clone in vb. when complete new level generates new map (roads bushes , cars move around) cars , roads work fine. don't want bushes generate on top of roads, tried make loop corrects issue. how refer many picture boxes 1 name, without having use mess of code made.
:)

 randomize()             bush1.location = new point(((me.size.width - 0 + 1) * rnd() + 1), ((me.size.height - 0 + 1) * rnd() + 1))     loop until bush1.bounds.intersectswith(picroad1.bounds) or bush1.bounds.intersectswith(picroad2.bounds) or bush1.bounds.intersectswith(picroad3.bounds) or bush1.bounds.intersectswith(picroad4.bounds) or bush1.bounds.intersectswith(picroad5.bounds)              bush2.location = new point(((me.size.width - 0 + 1) * rnd() + 1), ((me.size.height - 0 + 1) * rnd() + 1))     loop until bush1.bounds.intersectswith(picroad1.bounds) or bush1.bounds.intersectswith(picroad2.bounds) or bush1.bounds.intersectswith(picroad3.bounds) or bush1.bounds.intersectswith(picroad4.bounds) or bush1.bounds.intersectswith(picroad5.bounds)              bush3.location = new point(((me.size.width - 0 + 1) * rnd() + 1), ((me.size.height - 0 + 1) * rnd() + 1))     loop until bush1.bounds.intersectswith(picroad1.bounds) or bush1.bounds.intersectswith(picroad2.bounds) or bush1.bounds.intersectswith(picroad3.bounds) or bush1.bounds.intersectswith(picroad4.bounds) or bush1.bounds.intersectswith(picroad5.bounds)              bush4.location = new point(((me.size.width - 0 + 1) * rnd() + 1), ((me.size.height - 0 + 1) * rnd() + 1))     loop until bush1.bounds.intersectswith(picroad1.bounds) or bush1.bounds.intersectswith(picroad2.bounds) or bush1.bounds.intersectswith(picroad3.bounds) or bush1.bounds.intersectswith(picroad4.bounds) or bush1.bounds.intersectswith(picroad5.bounds)              bush5.location = new point(((me.size.width - 0 + 1) * rnd() + 1), ((me.size.height - 0 + 1) * rnd() + 1))     loop until bush1.bounds.intersectswith(picroad1.bounds) or bush1.bounds.intersectswith(picroad2.bounds) or bush1.bounds.intersectswith(picroad3.bounds) or bush1.bounds.intersectswith(picroad4.bounds) or bush1.bounds.intersectswith(picroad5.bounds)              bush6.location = new point(((me.size.width - 0 + 1) * rnd() + 1), ((me.size.height - 0 + 1) * rnd() + 1))     loop until bush1.bounds.intersectswith(picroad1.bounds) or bush1.bounds.intersectswith(picroad2.bounds) or bush1.bounds.intersectswith(picroad3.bounds) or bush1.bounds.intersectswith(picroad4.bounds) or bush1.bounds.intersectswith(picroad5.bounds)              bush7.location = new point(((me.size.width - 0 + 1) * rnd() + 1), ((me.size.height - 0 + 1) * rnd() + 1))     loop until bush1.bounds.intersectswith(picroad1.bounds) or bush1.bounds.intersectswith(picroad2.bounds) or bush1.bounds.intersectswith(picroad3.bounds) or bush1.bounds.intersectswith(picroad4.bounds) or bush1.bounds.intersectswith(picroad5.bounds) 

try out:

public class form1      private r new random     private roads() picturebox     private bushes() picturebox      private sub form1_load(sender object, e eventargs) handles mybase.load         roads = {picroad1, picroad2, picroad3, picroad4, picroad5}         bushes = {bush1, bush2, bush3, bush4, bush5, bush6, bush7}     end sub      private sub button1_click(sender object, e eventargs) handles button1.click         dim failed boolean = false         each bush picturebox in bushes                             failed = false                 bush.location = new point(r.next(me.clientsize.width), r.next(me.clientsize.height))                 each road picturebox in roads                     if bush.bounds.intersectswith(road.bounds)                         failed = true                         exit                     end if                 next             loop while failed         next     end sub  end class 

Comments

Popular posts from this blog

node.js - Using Node without global install -

How to access a php class file from PHPFox framework into javascript code written in simple HTML file? -

java - Null response to php query in android, even though php works properly -