Computer Science Canada Programming C, C++, Java, PHP, Ruby, Turing, VB   Username:   Password: Wiki   Blog   Search   Turing   Chat Room  Members
Need Help Urgently
Author Message
CyCLoBoT

Posted: 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

Delta

Posted: Fri Mar 21, 2003 9:50 am   Post subject: (No subject)

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.
CyCLoBoT

Posted: Fri Mar 21, 2003 11:21 am   Post subject: (No 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.
Tony

Posted: Fri Mar 21, 2003 11:57 am   Post subject: (No 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))
Tony's programming blog. DWITE - a programming contest.
 Display posts from previous: All Posts1 Day7 Days2 Weeks1 Month3 Months6 Months1 Year Oldest FirstNewest First

Page 1 of 1  [ 4 Posts ]
 Jump to:  Select a forum  CompSci.ca ------------ - Network News - General Discussion     General Forums   -----------------   - Hello World   - Featured Poll   - Contests     Contest Forums   -----------------   - DWITE   - [FP] Contest 2006/2008   - [FP] 2005/2006 Archive   - [FP] 2004/2005 Archive   - Off Topic     Lounges   ---------   - User Lounge   - VIP Lounge     Programming -------------- - General Programming     General Programming Forums   --------------------------------   - Functional Programming   - Logical Programming   - C     C   --   - C Help   - C Tutorials   - C Submissions   - C++     C++   ----   - C++ Help   - C++ Tutorials   - C++ Submissions   - Java     Java   -----   - Java Help   - Java Tutorials   - Java Submissions   - Ruby     Ruby   -----   - Ruby Help   - Ruby Tutorials   - Ruby Submissions   - Turing     Turing   --------   - Turing Help   - Turing Tutorials   - Turing Submissions   - PHP     PHP   ----   - PHP Help   - PHP Tutorials   - PHP Submissions   - Python     Python   --------   - Python Help   - Python Tutorials   - Python Submissions   - Visual Basic and Other Basics     VB   ---   - Visual Basic Help   - Visual Basic Tutorials   - Visual Basic Submissions     Education ----------- - Student Life   Graphics and Design ----------------------- - Web Design     Web Design Forums   ---------------------   - (X)HTML Help   - (X)HTML Tutorials   - Flash MX Help   - Flash MX Tutorials   - Graphics     Graphics Forums   ------------------   - Photoshop Tutorials   - The Showroom   - 2D Graphics   - 3D Graphics     Teams ------ - dTeam Public

 Style: Appalachia blueSilver eMJay subAppalachia subBlue subCanvas subEmjay subGrey subSilver subVereor Search: