Computer Science Canada

Need help putting random integers in fixed locations

Author:  GalacticVenus [ Sat Dec 05, 2009 7:23 pm ]
Post subject:  Need help putting random integers in fixed locations

What is it you are trying to achieve?
I'm making a turn-based RPG and would like to put the damage on the pictures of the Hero and the Enemy when it's dealt.
The damage is a random integer (10 to 22) plus the Hero's level squared plus (Power * 3 - 1) divided by 2.


What is the problem you are having?
I don't know how-- or even if it is possible to place a random number on a location on-screen.


Describe what you have tried to solve this problem
Mucking around with the command (Draw.Text, Draw.Num, Draw.Number, Number.Draw)
Looking in the manual thingy (And since it's me doing it, it's not very effective)
Swearing
Asking the computer nicely



Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)


Turing:


var HeroAttack : int
var text : int
text := Font.New ("impact:10")

HeroAttack := Rand.Int (10, 22) + level ** 2 + (Power * 3 - 1) div 2


Draw.Text (HeroAttack, 150, 150, text, red)



Please specify what version of Turing you are using
4.1.1

Author:  Tony [ Sat Dec 05, 2009 7:32 pm ]
Post subject:  Re: Need help putting random integers in fixed locations

GalacticVenus @ Sat Dec 05, 2009 7:23 pm wrote:

I don't know how-- or even if it is possible to place a random number on a location on-screen.

Well where did you get the idea to display the damage dealt in this way? Laughing

If you look at the error message closely, it will tell you that Font.Draw / Draw.Text expects a string to draw. So instead of number 12, you need to a word "12" to draw. You can convert from int to string with a use of intstr


: