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

Username:   Password: 
 RegisterRegister   
 Drawing a variable
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
element4l




PostPosted: Fri Sep 28, 2007 10:56 pm   Post subject: Drawing a variable

Once again, I come back with another question.

Lets say I wanted to draw some stats in the upper right corner of the window, so the user can keep track of their health and money etc.
How would I go about doing that if they're variables? I've tried just doing
code:
    var font : int
    font := Font.New ("serif:12")
    assert font > 0
    Font.Draw (health, 50, 30, font, red)
    Font.Free (font)

but it won't accept the variable since it should be inside quotations.

You guys are the best, any help would be great Wink
Sponsor
Sponsor
Sponsor
sponsor
HeavenAgain




PostPosted: Fri Sep 28, 2007 11:11 pm   Post subject: Re: Drawing a variable

im assuming the variable, health, that you used is a int variable?
so inorder to draw font, the thing that you want to draw must be a string.
so make a ummm string variable for health
see example below
Turing:

var font : int
var health : int := 100
var health_string : string
health = health - 10 %got hit
health_string = intstr (health)
font := Font.New ("serif:12")
assert font > 0
Font.Draw (health_string, 150, 30, font, red)
Font.Free (font)

the key to this is intstr, and strint, and also, Font.Draw is for string only. Shocked
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: