Is it possible to poll multiple buttons each frame using this method? In testing it, only the top conditional is registering meaning I've only access to the 'up' button. Thanks in advance for any advice!
Thank you very much both kouyama-senpai & Hanzo for your very helpful input!
Yes, it looks like I will divide from largest to smallest as I have in the past ;c these hashtags are not as much of a shortcut as I was thinking, they just equal out to the raw values.
The thing everyone is missing here, is the truth-iness of those values.
Anything that is not 0 will be considered true in an IF statement.
TRUE the keyword is just 1. So the top IF is working because 1==1.
you just need:
IF BUTTON() AND #DOWN THEN
Oh damn, as simple as treating both sides as complete conditionals, eh? After I already reorganized the whole thing, hah! I will remember, but it's okay as it is now as it all works accordingly. :3
Thanks! As always, you're an indispensable help Kl'Dck.
Too simply sample for biginners.
B=BUTTON()
IF B==1 THEN (Code of moving Up)
IF B==2 THEN (Code of moving Down)
IF B==4 THEN (Code of moving Left)
IF B==8 THEN (Code of moving Right)
IF B==16 THEN (Code of moving Shoot or Jump)
This pattern is enough to make and use a simple game!
I also used this when I was biginner.
Thank you for your input Kouyama, beginners should simply take into account that this kind of setup is not good for multiple button presses, but it's great for getting your game off the ground!
This setup works for multiple button presses if you use the boolean operation AND. Button() is a binary number where each position is a button. ANDing that with a button ID (think binary) will match if both have a 1 in the same position.
You can do mulitples by introducing OR. 01 OR 10 is 11 because there is a 1 in one OR the other of the numbers.
So:
IF BUTTON() AND (#A OR #X) THEN