Help with Randomization of Non-Overlapping Images

Tara Miskovich tamiskovich at gmail.com
Mon Jul 28 20:43:30 UTC 2014


Hello,

I am working on having 4 images randomly places within a rectangular region
without overlapping. I wrote the code below, and it appears to be working
with up to Image 3 added, but when I add in the forth image the program
freezes. I am hoping for some guidance with what to try next or how to get
past this. Here is the code I wrote to randomize the x and y location for
each image.

Thanks!
Tara

Dim x1 As Integer
Dim x2 As Integer
Dim x3 As Integer
Dim x4 As Integer
Dim y1 As Integer
Dim y2 As Integer
Dim y3 As Integer
Dim y4 As Integer

x1 = random(36, 42)
y1 = random(38, 60)

Do
x2 = random(36, 42)
y2 = random(38, 60)
x3 = random(36, 42)
y3 = random(38, 60)
x4 = random(36, 42)
y4 = random(38, 60)


Loop While (x2 = x1 Or x2 = x1 + 1 Or x2 = x1+2 Or x2 = x1 - 1 Or x2 = x1 -
2 _
And y2 = y1 Or y2 = y1 + 1 Or y2 = y1 + 2 Or y2 = y1 + 3 Or y2 = y1 - 1 Or
y2 = y1 - 2 Or y2 = y1 - 3)_
Or (x3 = x1 Or x3 = x1 + 1 Or x3 = x1+2 Or x3 = x1 - 1 Or x3 = x1 - 2 _
And y3 = y1 Or y3 = y1 + 1 Or y3 = y1 + 2 Or y3 = y1 + 3 Or y3 = y1 - 1 Or
y3 = y1 - 2 Or y3 = y1 - 3)_
Or (x3 = x2 Or x3 = x2 + 1 Or x3 = x2+2 Or x3 = x2 - 1 Or x3 = x2 - 2 _
And y3 = y2 Or y3 = y2 + 1 Or y3 = y2 + 2 Or y3 = y2 + 3 Or y3 = y2 - 1 Or
y3 = y2 - 2 Or y3 = y2 - 3)_
or (x4 = x1 Or x4 = x1 + 1 Or x4 = x1+2 Or x4 = x1 - 1 Or x4 = x1 - 2 _
And y4 = y1 Or y4 = y1 + 1 Or y4 = y1 + 2 Or y4 = y1 + 3 Or y4 = y1 - 1 Or
y4 = y1 - 2 Or y4 = y1 - 3)_
Or (x4 = x2 Or x4 = x2 + 1 Or x4 = x2 + 2 Or x4 = x2 - 1 Or x4 = x2 - 2 _
And y4 = y2 Or y4 = y2 + 1 Or y4 = y2 + 2 Or y4 = y2 + 3 Or y4 = y2 - 1 Or
y4 = y2 - 2 Or y4 = y2 - 3)_
Or (x4 = x3 Or x4 = x3 + 1 Or x4 = x3 + 2 Or x4 = x3 - 1 Or x4 = x3 - 2 _
And y4 = y3 Or y4 = y3 + 1 Or y4 = y3 + 2 Or y4 = y3 + 3 Or y4 = y3 - 1 Or
y4 = y3 - 2 Or y4 = y3 - 3)

c.SetAttrib "x1", x1
c.SetAttrib "x2", x2
c.SetAttrib "x3", x3
c.SetAttrib "x4", x4
c.SetAttrib "y1", y1
c.SetAttrib "y2", y2
c.SetAttrib "y3", y3
c.SetAttrib "y4", y4

-- 
You received this message because you are subscribed to the Google Groups "E-Prime" group.
To unsubscribe from this group and stop receiving emails from it, send an email to e-prime+unsubscribe at googlegroups.com.
To post to this group, send email to e-prime at googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/e-prime/CAKtjwHwOZDrq0o4ZQjAWQF9YfCv8isAEyPUg%2BucbUmqi6Py70A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listserv.linguistlist.org/pipermail/eprime/attachments/20140728/09e6a200/attachment.htm>


More information about the Eprime mailing list