The VEX Visual Studio Code Extension has replaced VEXcode Pro V5, which is now end-of-life.
VEXcode Blocks and VEXcode Text remain actively developed and supported for all VEX platforms.
Habrá momentos en los que le gustaría dar alguna información específica a la función. Esto permitirá a la función realizar su tarea en consecuencia en función de la información recibida cada vez que se llame. La siguiente muestra mostrará cómo funciona.
Muestra: Un programa dibuja una cara sonriente para mostrar usando parámetros
El siguiente ejemplo también ejemplifica las variables globales que se están utilizando correctamente.
Sin usar una función definida por el usuario:
int MaxX = 484, MaxY = 278;
int main() {vexcodeInit ();
int centerX = MaxX/2, centerY = MaxY/2;
//The face Brain.Screen.drawCircle (centerX, centerY, 100);
//The left eye
int space = 20; /*Esto proporciona el espaciado para el ojo en
relación con la parte superior de la pantalla. Puede ajustar esto como desee.*/centerX
= MaxX/2+espacio;
centerY = MaxY/2-30;
Brain.Screen.drawCircle (centerX, centerY, 20);
//El ojo derecho
/*...puede continuar haciendo el código para el ojo derecho aquí*
///La boca sonriente
/*...puede continuar haciendo el código para la boca sonriente aquí
... etc.
Si quieres dibujar un tamaño diferente, tendrás que repetir todo el conjunto de códigos de nuevo.
*/
}
Con una función definida por el usuario:
int MaxX = 484, MaxY = 278;
const char Left=1, Right=2;
void drawFace (int size){
/*...code for the face based on the size parameter from the caller funciton.*/
}
//side == Left or Right
void drawEye (char side){
/*...code for the eye based on the size parameter from the caller funciton.*/
}
//side == Left or Right
void drawMouth (bool smile, int size){
/*...code for the mouth based on the size parameter from the caller. Esto incluye si está sonriendo o frunciendo el ceño, así como el ancho.*/
}
int main()
{vexcodeInit (
); drawFace (
); drawEye (Left
); drawEye (Right);
//realmente puedes divertirte con esto...
while (true){
drawMouth(true, 30);
wait(1000, msec);
drawMouth(false, 30);
wait(1000, msec);
}
}
Aquí se muestra la secuencia del flujo lógico de la función de llamada main():