Computer Science Canada

Need Help Urgently

Author:  CyCLoBoT [ Fri Mar 21, 2003 7:49 am ]
Post subject:  Need Help Urgently

I would like to find the coordinates(I have showed in the picture) when there is one space between the circles. The two circles have to be on the same x-axis or the y-axis

code:
var wino := Window.Open ("graphics:480;480,noecho, nocursor")
Window.Set (wino, "title: " + "Atom and Ray")
var ballx, bally : array 1 .. 5 of int
for i : 1 .. 11 %Draws the grid
    drawline (60 + i * 30, 90, 60 + i * 30, 390, 17)
    drawline (90, 60 + i * 30, 390, 60 + i * 30, 17)
    drawline (60 + 30 * i, 30, 60 + 30 * i, 60, black)
    drawline (60 + 30 * i, 420, 60 + 30 * i, 450, black)
    drawline (30, 60 + 30 * i, 60, 60 + 30 * i, black)
    drawline (420, 60 + 30 * i, 450, 60 + 30 * i, black)
end for
for i : 1 .. 5
    %Randomly selects 5 x and 5 y cordinates and draws 5 circles
    ballx (i) := 90 + (Rand.Int (2, 9) * 30) - 15
    bally (i) := 90 + (Rand.Int (2, 9) * 30) - 15
    drawfilloval (ballx (i), bally (i), 13, 13, 7)
end for


Here is a picture that shows what I want:
http://funware.topcities.com/info.htm

Thanks

Author:  Delta [ Fri Mar 21, 2003 9:50 am ]
Post subject: 

Confused I'm a little confuse as to what you are trying to do. Maybe you could explain in a little more detail as to what you are trying to do. Then it will be easier to help you.

Author:  CyCLoBoT [ Fri Mar 21, 2003 11:21 am ]
Post subject: 

Everytime the program runs, it generates 5 random circles. So when any two of the circles are beside each other seperated by 1 box in between, I want to find the cordinate between those two circles.

Author:  Tony [ Fri Mar 21, 2003 11:57 am ]
Post subject: 

cant you just check for each of circles if there's another one nearby?

for i:1..5
for i2:1..5
if ballX(i)+2 = ballX(i2) then
match
elsif ballY(i)+2 = ballY(i2) then
match

etc...

for each of the balls, it checks its location to each of the other balls.

once you get a match, then the square in between is the coordinates you're looking for. Such as for the first match, it would be (ballX(i)+1, ballY(i))


: