
-----------------------------------
Mr. T
Sun Nov 06, 2005 2:34 pm

whatdotcolour
-----------------------------------
In my program, I implemented a flexible array so that the user could keep on making more and more new boxes.  However, when I try to use whatdotcolour to see if a newly created box is touching a previously created box, whatdotcolour doesn't pick up anything.  Is this a Turing defficiency or am I just doing something incorrectly?  Furthermore, aside from whatdotcolour, is there another way (possibly using Math.Distance) to compare the locations of two elements in the same flexible array?  If so, sample code would be appreciated.

-----------------------------------
[Gandalf]
Sun Nov 06, 2005 2:53 pm


-----------------------------------
For whatdotcolour to work, there must be something on the screen.  It will not work if you have something like this:

loop
cls
whatdotcolour
drawscreen
end loop

instead you should be doing this:

loop
cls
drawscreen
whatdotcolour
end loop

This is a probable cause to your problem, otherwise it would be good to see the code.

Math.Distance is the way to go, just compare the edges of each box in a loop, something like so:

for a : 1 .. upper (box)
    for b : 1 .. upper (box)
        check box a's borders compared to box b's
    end for
end for

Hope this helps, sorry I can't be of more assistance (example code) but I don't have too much time right now.

-----------------------------------
Mr. T
Sun Nov 06, 2005 3:00 pm

Alex's Opinion
-----------------------------------
The number of boxes is continuously increasing, which means I would need to continually increase the amount of for loops...how's that possible?

-----------------------------------
[Gandalf]
Sun Nov 06, 2005 3:37 pm


-----------------------------------
What?  No.  I may be misunderstanding you, but that is what upper (box) is for.  Every time you increase the amount of boxes, they will be taken into account the next time that loop structure is executed.  I have no idea why you would want to increase the amount of for loops...

-----------------------------------
Cervantes
Sun Nov 06, 2005 4:28 pm

Re: Alex's Opinion
-----------------------------------
The number of boxes is continuously increasing, which means I would need to continually increase the amount of for loops...how's that possible?
The two for loops are constant.  They compare every box against every other box.

And you wouldn't want to use Math.Distance for boxes.  Use it for circles, but for boxes just use some condition checking (if x1 >= x2 etc.)

-----------------------------------
Mr. T
Sun Nov 06, 2005 6:04 pm

Alex's Opinion
-----------------------------------
How would I put an exception into that process whereas the box checks every other box, EXCLUDING itself?

-----------------------------------
Cervantes
Sun Nov 06, 2005 8:13 pm


-----------------------------------
Using the indeces of the for loops that if a not= b then

-----------------------------------
Albrecd
Tue Nov 08, 2005 1:46 pm


-----------------------------------
or you could use:

 if X_box >= X_otherbox and X_box = Y_otherbox and Y_box = X_otherbox and X_box = Y_otherbox and Y_box 