El caso es que ando haciendo un Space Invaders con allegro y C pero noto que al mover la nave que en mitad del movimiento se ve y no se ve a la vez, se pone en modo fantasmagorico
Hice ya uno con Python y Pygame y no vi nunca ese efecto, y sin embargo ahora...
Ando usando doble buffering y la verdad no se otra manera mejor de implementar eso que estoy buscando para que no parpadee
En fin, os dejo el code a ver si algún erudito me ilumina
- Código: Seleccionar todo
- #include<allegro.h>
 #include<stdio.h>
 void iniciar()
 {
 allegro_init();
 
 set_color_depth(16);
 if(set_gfx_mode(GFX_AUTODETECT_WINDOWED,800,600,0,0)<0)
 {
 printf("Error al iniciar el modo grafico");
 allegro_exit();
 }
 install_keyboard();
 
 }
 
 void terminar()
 {
 allegro_exit();
 }
 
 void realizar_juego()
 {
 
 /*Declaracion de variables*/
 BITMAP *nave,*fondo,*laser;
 PALETTE paleta;
 int x,y, x_anterior, y_anterior, lasery, laserx, chivato;
 BITMAP *buffer,*buffer2;
 
 /*Carga de imagenes*/
 fondo=load_bitmap("/home/demenus/Escritorio/background.bmp",paleta);
 nave=load_bitmap("/home/demenus/Escritorio/xwing.bmp", paleta);
 laser=load_bitmap("/home/demenus/Escritorio/rebel_laser.bmp",paleta);
 set_palette(paleta);
 buffer=create_bitmap(800,600);
 
 
 /*Verificaciones*/
 if (nave==NULL) terminar();
 if (fondo==NULL) terminar();
 if (laser==NULL) terminar();
 if (buffer==NULL) terminar();
 x=SCREEN_W/2;
 y=SCREEN_H/2;
 
 
 
 /*main loop*/
 while (!key[KEY_ESC])
 {
 
 /*Controles*/
 if (key[KEY_UP])
 y=y-3;
 if (key[KEY_DOWN])
 y=y+3;
 if (key[KEY_LEFT])
 x=x-3;
 if (key[KEY_RIGHT])
 x=x+3;
 if (x<0) x=x_anterior;
 if (x>SCREEN_W-nave->w) x=x_anterior;
 if (y<0) y=y_anterior;
 if (y>SCREEN_H-nave->h) y=y_anterior;
 
 if (key[KEY_SPACE] && chivato==0)
 {
 lasery=y-nave->h/2;
 laserx=x+nave->w/2;
 draw_sprite(buffer,laser,laserx,lasery);
 chivato=1;
 }
 /*Controles*/
 {
 blit(fondo,buffer,0,0,0,0,fondo->w,fondo->h);
 draw_sprite(buffer,nave,x,y);
 if (chivato=1)
 {
 draw_sprite(buffer,laser,laserx,lasery);
 lasery=lasery-3;
 if (laser->h+lasery<=0) chivato=0;
 }
 blit(buffer,screen,0,0,0,0,800,600);
 clear_bitmap(buffer);
 }
 x_anterior=x;
 y_anterior=y;
 }
 
 destroy_bitmap(fondo);
 destroy_bitmap(laser);
 destroy_bitmap(nave);
 }
 
 int main()
 {
 iniciar();
 realizar_juego();
 
 readkey();
 allegro_exit();
 return 0;
 }
 END_OF_MAIN();
 
Espero ir bien en todo esto k ando haciendo =____=


