
-----------------------------------
element4l
Fri Sep 28, 2007 10:56 pm

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      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 ;)

-----------------------------------
HeavenAgain
Fri Sep 28, 2007 11:11 pm

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

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. :shock:
