Converting int to string
Author |
Message |
TuringDan
|
Posted: Sun Apr 13, 2008 1:57 pm Post subject: Converting int to string |
|
|
I want to convert an int variable into a string in order to display it using Draw.Text instead of put (to avoid the nasty background).
the int variable is health, it is constantly changing, and I want to display the number on my health bar.
Any help would be much appreciated.
also, this is my first post on these boards. |
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
[Gandalf]
![](http://compsci.ca/v3/uploads/user_avatars/189297994e4c716fec7f1.png)
|
Posted: Sun Apr 13, 2008 2:08 pm Post subject: RE:Converting int to string |
|
|
It's been a while since I've done Turing, but it goes something like this:
code: | Draw.Text("Health: " + intstr(health), x, y, colour) |
|
|
|
|
|
![](images/spacer.gif) |
TuringDan
|
Posted: Sun Apr 13, 2008 2:11 pm Post subject: Re: Converting int to string |
|
|
That worked! thanks a million. |
|
|
|
|
![](images/spacer.gif) |
[Gandalf]
![](http://compsci.ca/v3/uploads/user_avatars/189297994e4c716fec7f1.png)
|
Posted: Sun Apr 13, 2008 2:13 pm Post subject: RE:Converting int to string |
|
|
No problem, and welcome to CompSci.ca, enjoy your stay! ![Smile Smile](http://compsci.ca/v3/images/smiles/icon_smile.gif) |
|
|
|
|
![](images/spacer.gif) |
TuringDan
|
Posted: Sun Apr 13, 2008 2:16 pm Post subject: Re: Converting int to string |
|
|
Good to be here. I did a bit of turing in grade 9 and did not start again until this year (Im in grade 11)
I'm just teaching myself right now, and preparing for the grade 12 comp. info sciences course. I would have taken it this year but mandatory credits got in the way.
The code I wrote with your advice looks like this:
code: | Draw.Text (intstr(health)+" /160", 175, 321, font1, black)
Draw.Text (intstr(enemy1)+" /160", 505, 321, font1, black)
Draw.Text (intstr(enemy1mana)+" /160", 505, 306, font1, black) |
|
|
|
|
|
![](images/spacer.gif) |
Nick
![](http://compsci.ca/v3/uploads/user_avatars/19644337547e837b41d67a.png)
|
Posted: Sun Apr 13, 2008 2:34 pm Post subject: RE:Converting int to string |
|
|
looks good, but look up arrays in the Turing Walkthrough |
|
|
|
|
![](images/spacer.gif) |
|
|