Posted By: MattyTheG
Help with user-defined tilt angle. - 11/25/08 14:56
Last coding question for a while, I promise :P
Anyway I am working on this game where I want the user to be able to enter a number and have that number be set to the launch angle/ tilt of the gun. I have a global variable and a string, I use inkey to get the string and then str_to_num to convert it to a number, but then I used my.tilt = number, and it doesn't affect it. Perhaps seeing the code is better.
I don't understand why this wouldn't set my.tilt to the user_num.
I have a panel with the code "digits(300,40,"Launch angle: %f", *, 1, user_num);" and even after I enter the number I want, it still says 0.0000, so perhaps there is a problem with the string_to_num()?
Anyway I am working on this game where I want the user to be able to enter a number and have that number be set to the launch angle/ tilt of the gun. I have a global variable and a string, I use inkey to get the string and then str_to_num to convert it to a number, but then I used my.tilt = number, and it doesn't affect it. Perhaps seeing the code is better.
Code:
STRING* test = " "; var user_num = 0.00; action gun_shoot() { result = inkey(test); if (result == 13) { user_num = str_to_num(test); my.tilt = user_num; } }
I don't understand why this wouldn't set my.tilt to the user_num.
I have a panel with the code "digits(300,40,"Launch angle: %f", *, 1, user_num);" and even after I enter the number I want, it still says 0.0000, so perhaps there is a problem with the string_to_num()?