View Single Post
  #1   Spotlight this post!  
Unread 02-13-2015, 11:51 AM
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,002
Ether has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond repute
Re: Button Sequence Input

Quote:
Originally Posted by cgmv123 View Post
Code:
int state = 0;

while{
if buttonA && state == 0
state ++;

if buttonB && state == 1
state ++;

if buttonX && state == 2
state++;

if buttonY && state == 3
state ++;

if buttonBack
state = 0;

if state == 4
{action
state = 0;
}
This is Java-focused pseudocode, but it should be enough to get you started.
Shouldn't the state be reset to 0 if a button not in the A B X Y sequence is pressed?

As the code stands, the sequence A B Z X Y would be accepted.


Reply With Quote