• Welcome to Dark Bit Factory & Gravity.
 

Help reading two keys at once . . .

Started by DrewPee, September 28, 2010

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

DrewPee

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
DrewPee
aka Falcon of The Lost Boyz (Amiga)
Ex-Amiga Coder and Graphic Designer
Administrator of > www.retrocomputermuseum.co.uk

Jim

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
You need windows.bi in FB.

Jim
Challenge Trophies Won:

DrewPee

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
DrewPee
aka Falcon of The Lost Boyz (Amiga)
Ex-Amiga Coder and Graphic Designer
Administrator of > www.retrocomputermuseum.co.uk

Jim

You'd need to do

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

Jim
Challenge Trophies Won:

DrewPee

okay mate - thanks Jim! I will try this . . .  :) Very much appreciated! :)
DrewPee
aka Falcon of The Lost Boyz (Amiga)
Ex-Amiga Coder and Graphic Designer
Administrator of > www.retrocomputermuseum.co.uk

DrewPee

@Jim - thanks for that mate - it works fine! :) Just me being dumb (as usual).
Cheers
Andy
DrewPee
aka Falcon of The Lost Boyz (Amiga)
Ex-Amiga Coder and Graphic Designer
Administrator of > www.retrocomputermuseum.co.uk