help with draw random stars
Author |
Message |
Misha
|
Posted: Fri Oct 01, 2004 6:16 pm Post subject: help with draw random stars |
|
|
hi, i am new and i would like to know one thing. i did a whole code but i don't know how to draw as many stars as the user inputed. this is what i have for now
code: |
var x, y, x2, y2, col : int
var cont : string
var num : real
loop
cls
put "how many stars do you want to draw?"
get num
randomize
randint (x, 20, 500)
randint (y, 20, 500)
randint (x2, 1, 100)
randint (y2, 1, 100)
randint (col, 1, 30)
drawfillstar (x, y, x2, y2, col)
put "do u want to continue?"
get cont
cls
exit when cont = "N" or cont = "n"
end loop
|
thanx |
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
Dan
![](http://wiki.compsci.ca/images/archive/3/3c/20100325043407!Danspic.gif)
|
Posted: Fri Oct 01, 2004 6:38 pm Post subject: (No subject) |
|
|
Well i whould recomend using a for loop rather then a noraml loop and ether way you should ask the user for how many starts befor you start the loop.
So somting like this:
Quote:
Ask user for num starts
Input aswser
For loop that runs for num starts inputed
draw ramdom start
end for loop
The sintext for the for loop in turing is
for var:int : start point .. end point
so an example whould be:
code: |
for i: 1..num
randint (x, 20, 500)
randint (y, 20, 500)
randint (x2, 1, 100)
randint (y2, 1, 100)
randint (col, 1, 30)
drawfillstar (x, y, x2, y2, col)
end for
|
|
Computer Science Canada
Help with programming in C, C++, Java, PHP, Ruby, Turing, VB and more! |
|
|
|
![](images/spacer.gif) |
|
|