Author Topic: Help reading two keys at once . . .  (Read 4650 times)

0 Members and 1 Guest are viewing this topic.

Offline DrewPee

  • I Toast Therefore I am
  • Pentium
  • *****
  • Posts: 563
  • Karma: 25
  • Eat Cheese - It's good for you!
    • View Profile
    • Retro Computer Museum
Help reading two keys at once . . .
« 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
DrewPee
aka Falcon of The Lost Boyz (Amiga)
Ex-Amiga Coder and Graphic Designer
Administrator of > www.retrocomputermuseum.co.uk

Offline Jim

  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 5301
  • Karma: 402
    • View Profile
Re: Help reading two keys at once . . .
« Reply #1 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
You need windows.bi in FB.

Jim
Challenge Trophies Won:

Offline DrewPee

  • I Toast Therefore I am
  • Pentium
  • *****
  • Posts: 563
  • Karma: 25
  • Eat Cheese - It's good for you!
    • View Profile
    • Retro Computer Museum
Re: Help reading two keys at once . . .
« Reply #2 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
DrewPee
aka Falcon of The Lost Boyz (Amiga)
Ex-Amiga Coder and Graphic Designer
Administrator of > www.retrocomputermuseum.co.uk

Offline Jim

  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 5301
  • Karma: 402
    • View Profile
Re: Help reading two keys at once . . .
« Reply #3 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
Challenge Trophies Won:

Offline DrewPee

  • I Toast Therefore I am
  • Pentium
  • *****
  • Posts: 563
  • Karma: 25
  • Eat Cheese - It's good for you!
    • View Profile
    • Retro Computer Museum
Re: Help reading two keys at once . . .
« Reply #4 on: September 30, 2010 »
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

Offline DrewPee

  • I Toast Therefore I am
  • Pentium
  • *****
  • Posts: 563
  • Karma: 25
  • Eat Cheese - It's good for you!
    • View Profile
    • Retro Computer Museum
Re: Help reading two keys at once . . .
« Reply #5 on: October 03, 2010 »
@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