What is the best way to detect the player position during a button push. My logic seems right but why isn't this working? It's like it's not even registering the button.
Oops, the screenshot should have this code after the button push IF: IF X==21 AND Y==12 THEN INC KEY1. Combining all of that into one statement didn't work either.
AND is a logical gate that operates over two values, placing a 1-bit over all positions where both values have a 1-bit. AND should only be used in conditionals when working with BUTTON input.
For conventional conditional statements you should use the && operator. This one evaluates as true as long as the two expressions it joins also evaluate as true.
This means that your IF statements should look like this...
IF X==21 && Y==12 THEN 'DO SMTH
If you want to use button input at the same time you have to isolate the logical gates from the logical operators...
IF (B AND #A) && KEY1==0 THEN 'DO SMTH
Ah! I knew about using bit-wise operators in Java, but I didn't think about using them in Basic..Doh! Also that parenthesis part for button input is perfect thankyou! Oddly enough I got it working with AND in a nested IF statement.
AND has higher precedence than &&. In fact, && and || have the lowest precedence on the operator table, probably on account of their shortcutting. The parents around the AND shouldn't be necessary, unless I'm missing something.