|
Re: Creating a program that switch between tank and arcade
If you want to make the system remember whether you're currently on tank or arcade drive without using something like the Z-axis, you'd need to add a state field to the class, like:
bool isArcadeDrive = true;
Then, you'd modify that during each loop with conditionals to change it:
if( joystick->getRawButton(ArcadeButton)) {
isArcadeDrive = true;
}
else if ( joystick->getRawButton(TankButton)) {
isArcadeDrive = false;
}
This way, during each loop, your code constantly checks whether you've hit either button to switch driving modes, and the mode, being held in a field, is static during the program, so the program remembers whether you're in arcade or tank drive at any moment.
Next, you could add conditionals so that, depending on whether isArcadeDrive indicates arcade or tank driving, to use the drive code associated with either arcade or tank driving.
Example:
if(isArcadeDrive){
//Arcade drive code
}
else { //isArcadeDrive is false, therefore use Tank drive settings
//tank drive code
}
__________________
Attending: MN Duluth Regional
|