Author Topic: Handling multiple inputs at once  (Read 3331 times)

0 Members and 1 Guest are viewing this topic.

Offline ferbplatypult

  • LV1 Newcomer (Next: 20)
  • *
  • Posts: 15
  • Rating: +0/-0
    • View Profile
Handling multiple inputs at once
« on: June 28, 2022, 01:34:59 pm »
I’m making a wild guns remake for my ti-84 with axe and I’m wondering if it’s possible to receive multiple inputs like holding a button while moving a cursor. I feel like he answer may lie In the getkeyS command but I can’t get it to work properly. Does anyone know how to do it?

Offline Xeda112358

  • they/them
  • Moderator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 4704
  • Rating: +719/-6
  • Calc-u-lator, do doo doo do do do.
    • View Profile
Re: Handling multiple inputs at once
« Reply #1 on: June 28, 2022, 04:20:56 pm »
You were on the right track-- "getKey" on its own returns a single keypress, but you can also use "getKey(n)" to check if key "n" is pressed (it returns 0 for not pressed, 1 for pressed).

So if you want to check for both Enter and the Down arrow, simultaneously:
Code: [Select]
If getKey(9)
//Enter is pressed
End

If getKey(1)
//Down is pressed
End

You can also do some useful arithmetic, like if you have (X,Y) coordinates, you might want:
Code: [Select]
X+getKey(3)-getKey(2)→X
Y+getKey(1)-getKey(4)→Y
And that has a bonus of letting the user press multiple arrow keys simultaneously :)

Hopefully that helps!

EDIT: Also, welcome to Omninaga, you should Introduce Yourself!

Offline ferbplatypult

  • LV1 Newcomer (Next: 20)
  • *
  • Posts: 15
  • Rating: +0/-0
    • View Profile
Re: Handling multiple inputs at once
« Reply #2 on: June 28, 2022, 06:39:07 pm »
That works amazingly, thank you so much  :)