Gamestudio Links
Zorro Links
Newest Posts
Help with plotting multiple ZigZag
by degenerate_762. 04/30/24 23:23
M1 Oversampling
by 11honza11. 04/30/24 08:16
Trading Journey
by howardR. 04/28/24 09:55
Zorro Trader GPT
by TipmyPip. 04/27/24 13:50
Data from CSV not parsed correctly
by jcl. 04/26/24 11:18
Why Zorro supports up to 72 cores?
by jcl. 04/26/24 11:09
Eigenwerbung
by jcl. 04/26/24 11:08
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (degenerate_762, AndrewAMD), 877 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
wandaluciaia, Mega_Rod, EternallyCurious, howardR, 11honza11
19049 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Help with user-defined tilt angle. #238196
11/25/08 14:56
11/25/08 14:56
Joined: Jul 2007
Posts: 48
M
MattyTheG Offline OP
Newbie
MattyTheG  Offline OP
Newbie
M

Joined: Jul 2007
Posts: 48
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.

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()?

Re: Help with user-defined tilt angle. [Re: MattyTheG] #238204
11/25/08 16:01
11/25/08 16:01
Joined: Jul 2008
Posts: 553
Singapore
delinkx Offline
User
delinkx  Offline
User

Joined: Jul 2008
Posts: 553
Singapore
put a breakpoint inside the

if(result == 13)
{
....
...
}

and check if control is going there. I don't think its accepting keyboard entry like this.


A7 commercial Team / VC++ 2008 Pro
homepage | twitter | facebook
Re: Help with user-defined tilt angle. [Re: delinkx] #238269
11/26/08 00:48
11/26/08 00:48
Joined: Jul 2007
Posts: 48
M
MattyTheG Offline OP
Newbie
MattyTheG  Offline OP
Newbie
M

Joined: Jul 2007
Posts: 48
I think you're right. The manual shows it as calling a process_entry() function later but does not go into details as to what that function contains.
Would a code more like this work?
Code:
function process_entry(test)
{
   user_num = str_to_num(test);
}

action gun_shoot()
{
   result = inkey(test);
   if (result == 13)
   {
      process_entry(test);
   }
}


Something like that? I'm not sure what you mean by a breakpoint, I know how to use the break command in C++ but not sure what to do here.


Last edited by MattyTheG; 11/26/08 00:49.
Re: Help with user-defined tilt angle. [Re: MattyTheG] #238271
11/26/08 00:53
11/26/08 00:53
Joined: Oct 2008
Posts: 218
Nashua NH
heinekenbottle Offline
Member
heinekenbottle  Offline
Member

Joined: Oct 2008
Posts: 218
Nashua NH
a breakpoint is a //! at the end of a line that will, if you run with -debug, single step through a program if that instruction was reached.

Alternatively, you could use beep() in the if branch to see if the code is going that far.


I was once Anonymous_Alcoholic.

Code Breakpoint;
Re: Help with user-defined tilt angle. [Re: heinekenbottle] #238275
11/26/08 01:18
11/26/08 01:18
Joined: Jul 2007
Posts: 48
M
MattyTheG Offline OP
Newbie
MattyTheG  Offline OP
Newbie
M

Joined: Jul 2007
Posts: 48
Alright, thanks for clarifying that. Yea I used the beep() and there was no beep, so apparently the key command is not processing. Does anyone know why it wouldn't? I terminated the text with enter which is supposed to return 13 according to the manual.

Re: Help with user-defined tilt angle. [Re: MattyTheG] #238365
11/26/08 22:00
11/26/08 22:00
Joined: Aug 2007
Posts: 1,922
Schweiz
Widi Offline
Serious User
Widi  Offline
Serious User

Joined: Aug 2007
Posts: 1,922
Schweiz
There is a Bug in version 7.07, the inkey dont return the number of the key. I have the same problem. Use:

inkey(test);
if (result == 13)

and not:

result = inkey(test);
if (result == 13)

Re: Help with user-defined tilt angle. [Re: Widi] #238374
11/26/08 23:04
11/26/08 23:04
Joined: Jul 2007
Posts: 48
M
MattyTheG Offline OP
Newbie
MattyTheG  Offline OP
Newbie
M

Joined: Jul 2007
Posts: 48
That fixed the problem, thank you very much.


Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1