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

Username:   Password: 
 RegisterRegister   
 Font and random numbers
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
upthescale




PostPosted: Fri Mar 31, 2006 5:27 pm   Post subject: Font and random numbers

i know how to use font.Draw like make a word bigger and different font
and i can also use randint

code:

var x :int

randint (x,1,10)


but how do i put a random number inside the fontdraw, so in thoer words the pogram wud output a number, but in big lettering and whatever font u want?
Sponsor
Sponsor
Sponsor
sponsor
[Gandalf]




PostPosted: Fri Mar 31, 2006 5:35 pm   Post subject: (No subject)

You would use the + operator to concatenate the random number to the string you are outputting. Before you do this, you must use the intstr function to convert the integer to a string (so that it is able to be concatenated to the output string).
code:
Font.Draw ("The random number is: " + intstr(Rand.Int (1, 15)), 200, 150, myFont, red)

Note: We are using the Rand.Int (min, max : int) : int function instead of randint() in this case, because a function is much more appropriate.
do_pete




PostPosted: Fri Mar 31, 2006 5:38 pm   Post subject: (No subject)

This should be under [Turing Help]. Anyways, all you have to do is make the number and convert it to a string using "intstr". You may also want to use Rand.Int.
[Gandalf]




PostPosted: Fri Mar 31, 2006 5:41 pm   Post subject: (No subject)

You're a bit slow. Smile
Yes, this should definately be under [Turing Help]. [Turing Source Code] is for fully functional programs which others can learn from.

strint() would convert a string to an integer, check it out for yourself. An easy way to remember this is "__ to __", so in this case "string to int".

*edit* I'm not crazy... He had it as strint() before the edit. Smile
do_pete




PostPosted: Fri Mar 31, 2006 5:47 pm   Post subject: (No subject)

Oops! Embarassed I realized that, then I edited it and you posted that while while I was editing
upthescale




PostPosted: Fri Mar 31, 2006 6:26 pm   Post subject: (No subject)

ok i am using

code:

Font.Draw ("The random number is: " + intstr(Rand.Int (1, 15)), 200, 150, myFont, red)



fer a slots game i am making...i am done i am just coding it now ...i need it so if (x) = 3 and (x2) = 3 and (x3) = 3 then the person will win


but using
code:

Font.Draw ("The random number is: " + intstr(Rand.Int (1, 15)), 200, 150, myFont, red)

there are no variables so how do i do this?
[Gandalf]




PostPosted: Fri Mar 31, 2006 6:36 pm   Post subject: (No subject)

Replace Rand.Int (1, 15) with your integer variable.
upthescale




PostPosted: Fri Mar 31, 2006 6:37 pm   Post subject: (No subject)

how?
Sponsor
Sponsor
Sponsor
sponsor
[Gandalf]




PostPosted: Fri Mar 31, 2006 6:42 pm   Post subject: (No subject)

Wow... ugh... Double one word obvious post? Really, this should be self-evident:
code:
Font.Draw ("The random number is: " + intstr(myIntVar), 200, 150, myFont, red)
upthescale




PostPosted: Fri Mar 31, 2006 6:45 pm   Post subject: (No subject)

is it possible to make turing, in turing?
[Gandalf]




PostPosted: Fri Mar 31, 2006 6:56 pm   Post subject: (No subject)

Random question?

Well... you could recreate many aspects of it, since you would only need to parse the code and call the corresponding Turing functions. To recreate the whole thing would be incredibely useless, and, although it's definately possible (basically anything is with a programming language) why would you want to do it?
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  [ 11 Posts ]
Jump to:   


Style:  
Search: