Dark Bit Factory & Gravity

PROGRAMMING => Freebasic => Topic started by: DrewPee on September 28, 2010

Title: Help reading two keys at once . . .
Post by: DrewPee on September 28, 2010
Hello again all, good to be back on here.
Can anybody help me with this one, is it possible to read two keys at once using tinyptc?
It is not demo related but something that I have wanted to do for years . . . code a platform game.
I can't figure out if it is possible to press two keys together to make my character jump left and right.

Cheers

Andy
Title: Re: Help reading two keys at once . . .
Post by: Jim on September 28, 2010
I thought ptc had a key reading routine, but I can't find it.
It should be easy without it though, you can call
GetAsyncKeyState() directly for each key you want to check.
http://msdn.microsoft.com/en-us/library/ms646293(v=vs.85).aspx (http://msdn.microsoft.com/en-us/library/ms646293(v=vs.85).aspx)
You need windows.bi in FB.

Jim
Title: Re: Help reading two keys at once . . .
Post by: DrewPee on September 30, 2010
Thanks Jim.
Can GetASyncKeyState() read more than one key at a time though - I can't seem to get it to do that?
Cheers
Andy
Title: Re: Help reading two keys at once . . .
Post by: Jim on September 30, 2010
You'd need to do

key1 = GetAsyncKeyState('A');
key2 = GetAsyncKeyState('B');
if (key1 && key2)   
or
if key1 AND key2 then

Jim
Title: Re: Help reading two keys at once . . .
Post by: DrewPee on September 30, 2010
okay mate - thanks Jim! I will try this . . .  :) Very much appreciated! :)
Title: Re: Help reading two keys at once . . .
Post by: DrewPee on October 03, 2010
@Jim - thanks for that mate - it works fine! :) Just me being dumb (as usual).
Cheers
Andy