View Single Post
  #6   Spotlight this post!  
Unread 11-06-2010, 22:59
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,101
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: no control of bot when kicker is operating

What you've posted is essentially a state machine, where the state variable is the value of kickTimer.

A generic state machine might look like this:


Quote:
// Set kicking loop to start when button 7 on gamepad is pressed and not in loop already


switch(kickState) {

case 0: // kicking is not in progress

if(gamePad.getRawButton(7) == true) {
start_the_kick_sequence_and_initialize_variables_a s_necessary();
kickState = 1;
}
break;

case 1:

if case_1_timer_or_event_has occurred(){
perform_case_1_action();
initialize_variables_for_case_2_as_necessary();
kickState=2;
}
break;

case 2:

if case_2_timer_or_event_has occurred(){
perform_case_2_action();
initialize_variables_for_case_3_as_necessary();
kickState=3;
}
break;

.
.
.


case n:

if case_n_timer_or_event_has occurred(){
perform_casen2_action();
initialize_variables_for_case_0_as_necessary();
kickState=0;
}
break;

}

The above has the advantage that it's a little easier to see how to use events (like limit switches etc) to change states, instead of being strictly timer-based.


~

Last edited by Ether : 12-06-2010 at 00:53.