forums

TNT Basic Forums > Programming Q&A
Draw text with variable?
< Last Thread     Next Thread >
Author
Thread        Post A Reply

01-16-2003 23:54

Posted by:
Ashlin Aronin

Click Here to Email Ashlin Aronin   Find more posts by Ashlin Aronin

Is there any way to use the draw text command with a variable integer instead of a string? I tried it with quotes:
draw text x,y,"variable"
and without quotes:
draw text x,y,variable
but the first one draws "variable" and the second returns an error (expected a string).
Thanks,
Ashlin

01-17-2003 04:30

Posted by:
eLL

Click Here to Email eLL   Find more posts by eLL

try this

[code]
graphics mode 1024,768

int domino = 50
int cerulean = 100
string ripe

ripe= ripe + "paprika stings my eyes"

while not mouse button
draw text domino,cerulean,ripe
draw frame
wend
[/code]

try that instead of a literal string you can use a string variable and as you can see from my very bizarre example you achieve the desired effect.

01-17-2003 04:37

Posted by:
eLL

Click Here to Email eLL   Find more posts by eLL

oh yeah

you know the word vaariable is probably reserved and other than that i doubt that you declared a variable of type string, which is what it meant by expected string.

you would have gotten the same error if oyu hadn't defined x and y...something like expected integer

01-17-2003 10:16

Posted by:
Danlab games

Click Here to Email Danlab games   Find more posts by Danlab games

you can try some thing like that:

draw text 100,100,as string(variable)

01-18-2003 23:15

Posted by:
Ashlin Aronin

Click Here to Email Ashlin Aronin   Find more posts by Ashlin Aronin

Thanks Danlab. your solution works great with stationary text, but (and I should of said this earlier) I'm using it for a health bar, and whenever the health of the character decreases, the text continually overwrites itself, forming writhing blobs. How can I stopTNT from doing this? I searched past posts, and found that I could use Fill Rect to fix this. I tried that, but it didn't work. Here's my code:
text size 45
set pen colour white
text font "Verdana"
draw text 886,759,as string(wizardHealth)
set pen colour make colour (0,102,255)
fill rect 886,759 to 1024,768

01-20-2003 07:30

Posted by:
Danlab games

Click Here to Email Danlab games   Find more posts by Danlab games

you can draw a black square and a with text each time ?

All times are GMT        Post A Reply

Forum Jump:
< Last Thread     Next Thread >

< Contact Us - TNT Basic >

Powered by: vBulletin Lite Version 1.0.1 Lite
Copyright © Jelsoft Enterprises Limited 2000.