This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define DIRECCION_DERECHA 0 | |
#define DIRECCION_IZQUIERDA 1 | |
#define DIRECCION_ARRIBA 2 | |
#define DIRECCION_ABAJO 3 | |
int direccion = DIRECCION_DERECHA; | |
void cambiarDireccion(int nuevaDireccion) { | |
if ( | |
nuevaDireccion != DIRECCION_DERECHA | |
&& nuevaDireccion != DIRECCION_IZQUIERDA | |
&& nuevaDireccion != DIRECCION_ARRIBA | |
&& nuevaDireccion != DIRECCION_ABAJO | |
) { | |
return; | |
} | |
if ( | |
(nuevaDireccion == DIRECCION_DERECHA || nuevaDireccion == DIRECCION_IZQUIERDA) | |
&& (direccion == DIRECCION_DERECHA || direccion == DIRECCION_IZQUIERDA) | |
) return; | |
if ( | |
(nuevaDireccion == DIRECCION_ARRIBA || nuevaDireccion == DIRECCION_ABAJO) | |
&& (direccion == DIRECCION_ARRIBA || direccion == DIRECCION_ABAJO) | |
) return; | |
direccion = nuevaDireccion; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment