Need Help
Author |
Message |
CyCLoBoT
|
Posted: Fri Feb 14, 2003 11:38 am Post subject: Need Help |
|
|
I would like to draw random circles in this 10x10 box. Any suggestions on how I can do that?
code: | for i : 1 .. 11
drawline (60 + 30 * i, 90, 60 + 30 * i, 390, black)
drawline (90, 60 + 30 * i, 390, 60 + 30 * i, black)
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 |
|
|
|
|
|
|
Sponsor Sponsor
|
|
|
Tony
|
Posted: Fri Feb 14, 2003 3:17 pm Post subject: (No subject) |
|
|
you can use randint(x,1,10) and randint(y,1,10) to randomly select a box to draw in... then you multiply each value by your box width (i assume 30) and add boarder size... thats the center of the circle you have to draw. |
Tony's programming blog. DWITE - a programming contest. |
|
|
|
|
CyCLoBoT
|
Posted: Sat Feb 15, 2003 3:16 am Post subject: (No subject) |
|
|
I tried it but was unable to draw the circles. If anyone can try to code it, I would really appreciate it. |
|
|
|
|
|
Tony
|
Posted: Sat Feb 15, 2003 8:02 am Post subject: (No subject) |
|
|
umm... did you try drawfilloval(x,y,xRadius,yRadius,color) ?
your xRadius and yRadius are 15 and you randomly select x and y using randint() |
Tony's programming blog. DWITE - a programming contest. |
|
|
|
|
CyCLoBoT
|
Posted: Sat Feb 15, 2003 3:37 pm Post subject: (No subject) |
|
|
The thing is that I want to in a way that everytime the user runs the program it draws 5 circles randomly in any one of the squares of 10x10 grid. |
|
|
|
|
|
Tony
|
Posted: Sat Feb 15, 2003 4:31 pm Post subject: (No subject) |
|
|
so randomly select a square and draw a circle in there... I fail to see what you need help with. Please be more specific |
Tony's programming blog. DWITE - a programming contest. |
|
|
|
|
CyCLoBoT
|
Posted: Sun Feb 16, 2003 1:55 am Post subject: (No subject) |
|
|
I have drawn the 10x10 boxes with lines. So how do I know which box to randomly select and put a circle in that particular box. |
|
|
|
|
|
Izzy
|
Posted: Sun Feb 16, 2003 2:25 am Post subject: (No subject) |
|
|
Here'yar
code: |
% Sets up the windos display features'
setscreen ("graphics:vga")
setscreen ("graphics:502;502")
% sets up the lines creating the 10x10 field (This one sets up the horizontal lines)
for y : 0 .. 500 by 50
drawline (0, y, 500, y, 15)
end for
% sets up the lines creating the 10x10 field (This one sets up the vertical lines)
for x : 0 .. 500 by 50
drawline (x, 0, x, 500, 15)
end for
% declaration of variables
var x, y : int := 25
var RandX, RandY, ColorIsCooler : int
% Repeats the code x10
for SetupTable : 1 .. 10
% Genereates Random Numbers to be used
% Randomly selects a color
randint (ColorIsCooler, 1, 15)
% Randomly selects a box on the x-axis
randint (RandX, 0, 9)
% Randomly selects a box on the y-axis
randint (RandY, 0, 9)
% A little math to change a number from 0-9 to a number that fits the box setup
x := (RandX * 50) + x
y := (RandY * 50) + y
% Draws the oval
drawfilloval (x, y, 23, 23, ColorIsCooler)
% Resets the x and y values because we are going to re-use the code
x := 25
y := 25
end for
|
- Izzy
*Edited to add programmers comments (sorry forgot)*
*Edited again... lol. wrong programmers comment meathod (used ' instead of %) gimme a break i've been using other languages * |
|
|
|
|
|
Sponsor Sponsor
|
|
|
Tony
|
Posted: Sun Feb 16, 2003 5:58 am Post subject: (No subject) |
|
|
mmm.... VB
if anyone sees me using // for comments, thats from C++ |
Tony's programming blog. DWITE - a programming contest. |
|
|
|
|
CyCLoBoT
|
Posted: Mon Feb 17, 2003 1:43 am Post subject: (No subject) |
|
|
thank you all for your help. I really appreciate it |
|
|
|
|
|
|
|