Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 help with draw random stars
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Misha




PostPosted: 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
Sponsor
Sponsor
Sponsor
sponsor
Dan




PostPosted: 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!
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 2 Posts ]
Jump to:   


Style:  
Search: