Dark Bit Factory & Gravity
PROGRAMMING => Freebasic => Topic started 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
-
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
-
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
-
You'd need to do
key1 = GetAsyncKeyState('A');
key2 = GetAsyncKeyState('B');
if (key1 && key2)
or
if key1 AND key2 then
Jim
-
okay mate - thanks Jim! I will try this . . . :) Very much appreciated! :)
-
@Jim - thanks for that mate - it works fine! :) Just me being dumb (as usual).
Cheers
Andy