im trying to make a simple program that has one BITMAP that is the "background" and another BITMAP that i can move, ive tried different ways, like drawing the background directly to screen, tried making two buffers, ive tried putting both BITMAPS in one buffer. right now im running the program with both in the buffer called twice in a loop. but the moveable BITMAP flashes.
#include <allegro.h>
int main(int argc, char *argv[])
{
allegro_init();
install_keyboard();
set_color_depth(16);
set_gfx_mode(GFX_AUTODETECT, 640,480,0,0);
BITMAP *my_pic = NULL;
my_pic = load_bitmap("image.bmp", NULL);
BITMAP *my_pics;
my_pics = load_bitmap("picture.bmp", NULL);
BITMAP *buffer = NULL;
buffer = create_bitmap(640,480);
BITMAP *bitty=NULL;
bitty = create_bitmap(640,480);
int my_pic_x = 0;
int my_pic_y = 0;
int my_pics_x=0;
int my_pics_y=0;
while(!key[KEY_ESC])
{
if(key[KEY_RIGHT])
{
my_pic_x ++;
}
else if(key[KEY_LEFT])
{
my_pic_x --;
}
else if(key[KEY_UP])
{
my_pic_y --;
}
else if(key[KEY_DOWN])
{
my_pic_y ++;
}
draw_sprite(bitty,my_pic,my_pic_x,my_pic_y);
//draw_sprite( screen, my_pic, 0, 0);
blit(bitty, screen, 0,0,0,0,640,480);
clear_bitmap(bitty);
draw_sprite(buffer,my_pics,my_pics_x,my_pics_y);
blit(buffer, screen, 0,0,0,0,640,480);
clear_bitmap(buffer);
}
destroy_bitmap(my_pic);
destroy_bitmap(my_pics);
destroy_bitmap(buffer);
destroy_bitmap(bitty);
return 0;
}
END_OF_MAIN()