? bin$(button()) is great! (Page 1) ● SmileBASIC Source Forums

Sign In

Register
*Usernames are case-sensitive
Forgot my password

bin$(button()) is great!

  • #1 ✎ 34 OneFloweyBoi I just found an amazing way to do multi-button input. Try this: ACLS WHILE 1 PRINT BIN$(BUTTON()) VSYNC CLS WEND Posted Edited by OneFloweyBoi
  • #2 ✎ 225 banana RNG Hidden Easter Eggs Third Year My account is over 3 years old Website Expert Programmer Programming no longer gives me any trouble. Come to me for help, if you like! Programming Strength You can also do multi-button input using the AND operator: 'Check L and R WHILE 1 IF BUTTON(1) AND (#L OR #R) THEN PRINT "L and R!" VSYNC WEND This works because the return value of BUTTON is a bitmask, that means every button has a single bit in the return value. The AND operator will return all the shared bits in both operands (&b1001 AND &b1011 == &b1001), and OR will return all the bits in both (&b1001 OR &b0110 == &b1111) Posted
  • #3 ✎ 1133 random_god Intermediate Programmer I can make programs, but I still have trouble here and there. Programming Strength Second Year My account is over 2 years old Website Forum Leader Hidden Achievements Tbh, you don't need to do exactly ?BIN$(BUTTON()) you can do just ?BUTTON() or ?BUTTON(0) BIN$ just makes it binary. It's what you put in () after BUTTON that effects that. Look at the help page for button. Posted
  • #4 ✎ 34 OneFloweyBoi Mid$()!!! Posted
  • #5 ✎ 1133 random_god Intermediate Programmer I can make programs, but I still have trouble here and there. Programming Strength Second Year My account is over 2 years old Website Forum Leader Hidden Achievements
    Mid$()!!!
    what does that have to do with this?
    Posted