# Option joystick-head-control Controls head with a joystick ## State Machine ## State straight
If that state is active,
> | The option joystick-playing is executed.
> | These output symbols are set:
| head-control-mode | = | head-control-mode.look-straight-ahead
The decision tree:
Pseudo code of the decision tree:
if ( | joystick-data.coolie == no-coolie | ) | // coolie center
{
transition-to-state(straight);
}
else if ( | joystick-data.coolie == S | ) | // coolie up
{
transition-to-state(up);
}
else if ( | joystick-data.coolie == N | ) | // coolie down
{
transition-to-state(down);
}
else if ( |
( | joystick-data.coolie == W | )
( | joystick-data.coolie == NW | )
( | joystick-data.coolie == SW | )
| ) | // coolie left
{
transition-to-state(left);
}
else if ( |
( | joystick-data.coolie == E | )
( | joystick-data.coolie == NE | )
( | joystick-data.coolie == SE | )
| ) | // coolie right
{
transition-to-state(right);
}
else
{
transition-to-state(straight);
}

## State up

If that state is active,
> | The option joystick-playing is executed.
> | These output symbols are set:
| head-control-mode | = | head-control-mode.look-to-stars
The decision tree:
Pseudo code of the decision tree:
if ( | joystick-data.coolie == no-coolie | ) | // coolie center
{
transition-to-state(straight);
}
else if ( | joystick-data.coolie == S | ) | // coolie up
{
transition-to-state(up);
}
else if ( | joystick-data.coolie == N | ) | // coolie down
{
transition-to-state(down);
}
else if ( |
( | joystick-data.coolie == W | )
( | joystick-data.coolie == NW | )
( | joystick-data.coolie == SW | )
| ) | // coolie left
{
transition-to-state(left);
}
else if ( |
( | joystick-data.coolie == E | )
( | joystick-data.coolie == NE | )
( | joystick-data.coolie == SE | )
| ) | // coolie right
{
transition-to-state(right);
}
else
{
transition-to-state(up);
}

## State down

If that state is active,
> | The option joystick-playing is executed.
> | These output symbols are set:
| head-control-mode | = | head-control-mode.look-between-feet
The decision tree:
Pseudo code of the decision tree:
if ( | joystick-data.coolie == no-coolie | ) | // coolie center
{
transition-to-state(straight);
}
else if ( | joystick-data.coolie == S | ) | // coolie up
{
transition-to-state(up);
}
else if ( | joystick-data.coolie == N | ) | // coolie down
{
transition-to-state(down);
}
else if ( |
( | joystick-data.coolie == W | )
( | joystick-data.coolie == NW | )
( | joystick-data.coolie == SW | )
| ) | // coolie left
{
transition-to-state(left);
}
else if ( |
( | joystick-data.coolie == E | )
( | joystick-data.coolie == NE | )
( | joystick-data.coolie == SE | )
| ) | // coolie right
{
transition-to-state(right);
}
else
{
transition-to-state(down);
}

## State left

If that state is active,
> | The option joystick-playing is executed.
> | These output symbols are set:
| head-control-mode | = | head-control-mode.look-left
The decision tree:
Pseudo code of the decision tree:
if ( | joystick-data.coolie == no-coolie | ) | // coolie center
{
transition-to-state(straight);
}
else if ( | joystick-data.coolie == S | ) | // coolie up
{
transition-to-state(up);
}
else if ( | joystick-data.coolie == N | ) | // coolie down
{
transition-to-state(down);
}
else if ( |
( | joystick-data.coolie == W | )
( | joystick-data.coolie == NW | )
( | joystick-data.coolie == SW | )
| ) | // coolie left
{
transition-to-state(left);
}
else if ( |
( | joystick-data.coolie == E | )
( | joystick-data.coolie == NE | )
( | joystick-data.coolie == SE | )
| ) | // coolie right
{
transition-to-state(right);
}
else
{
transition-to-state(left);
}

## State right

If that state is active,
> | The option joystick-playing is executed.
> | These output symbols are set:
| head-control-mode | = | head-control-mode.look-right
The decision tree:
Pseudo code of the decision tree:
if ( | joystick-data.coolie == no-coolie | ) | // coolie center
{
transition-to-state(straight);
}
else if ( | joystick-data.coolie == S | ) | // coolie up
{
transition-to-state(up);
}
else if ( | joystick-data.coolie == N | ) | // coolie down
{
transition-to-state(down);
}
else if ( |
( | joystick-data.coolie == W | )
( | joystick-data.coolie == NW | )
( | joystick-data.coolie == SW | )
| ) | // coolie left
{
transition-to-state(left);
}
else if ( |
( | joystick-data.coolie == E | )
( | joystick-data.coolie == NE | )
( | joystick-data.coolie == SE | )
| ) | // coolie right
{
transition-to-state(right);
}
else
{
transition-to-state(right);
}