Hola Sidus,
En primer lugar el error te sale por que estas utilizando una variable
(buffer) que no ha sido declarada en la funcion, la declaraste en el funcion
CARGAR_NAVE pero no en MOVER_ NAVE que es donde la usas. Ademas en la
funcion MOVER_NAVE no deberias volver a llamara a set_gfx_mode y todas esas
cosas por que ya lo hiciste en CARGAR_NAVE. Ademas no deberias llamara a
MOVER_NAVE desde CARGAR_NAVE sino desde main (para que sea mas
estructurado). Para aprender a estructurar mejor el programa, puedes leer un
poco mas sobre C, un buen curso lo puedes encontrar en
http://c.conclase.net
----- Original Message -----
From: "Sidus" <sidus@...>
To: "Lista de Allegro en español @gaspar.local"
<allegro-espanol@yahoogroups.com>
Sent: Tuesday, September 02, 2003 7:45 PM
Subject: [AL-ES] Transferencias de valores entre funciones
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Tengo dos funciones: 1) carga la imagen de una nave; 2) mueve esa misma
nave.
> Mi intención es hacer el programa lo más estructural posible.
> Una de ellas (CARGAR_NAVE) le pasa un valor a la otra (MOVER NAVE).
> Mis dudas son:
> 1) ¿transferi bien los valores?
> 2) El compilador me tira el siguiente error: 'BUFFER' UNDECLARED (FIRST
USE
> IN THIS FUNCTION y no sé porque.
>
> Muchísimas gracias.
>
>
>
> int main(int argc, char *argv[]) {
>
> CARGAR_NAVE();
>
> }
> END_OF_MAIN();
>
> //--------------------------------------------------//
> // FUNCION QUE CARGA LA IMAGEN DE LA NAVE //
> //--------------------------------------------------//
> CARGAR_NAVE () {
> PALETTE pal;
> int x, y; //TAMBIEN PARA EL MOVIMIENTO
> BITMAP *image;
>
> BITMAP *buffer; //PARA EL MOVIMIENTO
>
> allegro_init();
> install_keyboard();
> set_color_depth(8);
> if (set_gfx_mode(GFX_AUTODETECT, 1024, 768, 0, 0) != 0) {
> allegro_message("Error al establecer el modo gráfico\n%s\n",
allegro_error);
> return 1;
> }
>
> image =load_bitmap(IMAGEN_NAVE, pal);
> set_palette(pal);
> MOVER_NAVE(image); //LLAMO A LA OTRA FUNCION ¿ESTA BIEN PASADO?
> return 0;
> }
>
>
> //------------------------------------------------------//
> // FUNCION QUE DEBERIA DAR MOVIMIENTO A LA NAVE //
> //------------------------------------------------------//
> MOVER_NAVE(BITMAP *image) { //¿esta bien declarado?
> allegro_init();
> install_keyboard(); //INSTALO EL TECLADO
> set_color_depth(8); // FIJO EL MODO A 256 COLORES
>
> if (set_gfx_mode(GFX_AUTODETECT, 1024, 768, 0, 0) != 0) {
> allegro_message("Error al establecer el modo gráfico\n%s\n",
allegro_error);
> return 1;
> }
>
> buffer = create_bitmap (SCREEN_W, SCREEN_H); //EL ERROR ME SALE ACA
> //'BUFFER' UNDECLARED (FIRST USE IN THIS
FUNCTION*/
>
> clear(buffer); //LIMPIO EL BUFFER
> x = X_INICIAL;
> y = Y_INICIAL;
>
> while (!key[KEY_ESC]) {
>
> if (key[KEY_LEFT] && x > BORDE_IZQUIERDO) x=x-VELOCIDAD_MOVIMIENTO;
>
> if (key[KEY_RIGHT] && (x < BORDE_DERECHO))
x=x+VELOCIDAD_MOVIMIENTO;
>
> draw_sprite (buffer, image, x, y);
>
> blit(buffer,screen,0,0,0,0,SCREEN_W,SCREEN_H);
> clear(buffer); //LIMPIO EL BUFFER
> }
>
> return 0;
> }
>
>
> - --
> Llave Gnupg en:
> http://pgp.rediris.es:11371/pks/lookup?op=get&search=0x6F1FD83E
>
> Key fingerprint = F619 9CB9 8E42 0287 8386 D2ED AEBA 0FC5 6F1F D83E
>
>
>
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.0.6 (GNU/Linux)
> Comment: For info see http://www.gnupg.org
>
> iEYEARECAAYFAj9VOZ8ACgkQrroPxW8f2D4IxgCePp29M1R1w4pdUAaqXiZiXVec
> m9cAn0tRo1llZyH6BFYKEZIgfRwMNpf/
> =FOFr
> -----END PGP SIGNATURE-----
>
> _______________________________________________
> Para cancelar su subscripción envíe un email a:
> allegro-espanol-unsubscribe@egroups.com
>
>
> La utilización de Yahoo! Grupos está sujeta a su aceptación de las
> Condiciones del servicio (http://es.docs.yahoo.com/info/utos.html) así
> como de la Política de privacidad (http://privacy.yahoo.com/es/).
>
>
>
>
>