backSprites and double buffering


I'm doing a game with DJGPP and Allegro (actually it's my first PC-game) and I've got a little problem. How can I move sprites, is there a command in Allegro to do it? And another question: How can I do the double buffering?

Move sprites by erasing the previous sprite and drawing it in a new location. Double buffering is simply drawing to a BITMAP buffer the same size as your screen and then blitting that buffer on to the screen when you are done drawing.
If you want to use a background with your sprite, then draw the background before the main loop. Then, in the main loop, blit a small BITMAP (the same size as your sprite) from where your sprite is going to be drawn into a temporary buffer. Next, draw your sprite onto the main buffer and blit the buffer onto the screen. The next time through the loop, just put that little BITMAP that you blitted earlier back to its original location (this will erase the sprite) and go through the whole process again.

Wasn't this posted already before? I guess nobody answered. I'll try to answer this briefly:
for simplicity of this example let's create a structure that is the sprite:
typedef struct SPRITE {
   int x_loc, y_loc;//location of the sprite
   int x_off, y_off;//this the offset of the sprite. How much 
		      it moves each frame or just call it speed
   BITMAP *bmp; //this is the graphics for the sprite
} SPRITE;

SPRITE main_sprite; //this is the sprite variable
RGB *main_pallete;  //this is the pallete
then in your program you have to initizlize all that stuff
void Initialize(SPRITE *spr)
{
   spr->x_loc = 10;
   spr->y_loc = 10;
   spr->x_off = 3;
   spr->y_off = 3;
   spr->bmp = load_bitmap("somebmp.pcx", main_pallete);
}

main()
{
//do all the allegro initization stuff 
//
//...
Initialize(&main_sprite);
while (1) {
   if (key[KEY_ESC]) break; //if esc pressed exit
   else if (key[KEY_UP]) spr.y_loc -= spr.y_off; //move up
   else if (key[KEY_DOWN]) spr.y_loc += spr.y_off;  //move down
   else if (key[KEY_RIGHT]) spr.x_loc += spr.x_off; //move right
   else if (key[KEY_LEFT]) spr.x_loc -= spr.x_off; //move left
   //in here do all the drawing stuff for the sprite depending which 
   //method you use; if you use dirty rectangles you might have to
   //save the location of the sprite before you change it to restore 
   //the previous space
} //end while
}
as of the question about double buffering you can modify the previous piece of code to make an example out of that for your global variable add:
BITMAP *double_buffer;
and in main before the while loop
double_buffer = create_bitmap(size_x, size_y);
size_x and size_y are the size of the buffer you want to use. It's the drawing area, you might not want to blit the whole screen every frame and then you can add a function for drawing:
void DrawScreen(void)
{
   clear(double_buffer); //clear the double buffer
   //now draw the sprite
   draw_sprite(double_buffer, spr.bmp, spr.x_loc, spr.y_loc);
   //and now blit the double buffer to screen
   blit(double_buffer, screen, 0, 0, screen_x, screen_y, 
   double_buffer->w, double_buffer->h);
   //screen_x and screen_y is the location of the bitmap on screen
}
you might also change a while loop of this example to add some delay to it. I did not test this piece of code so I do not guarantee it will work. I hope that helps, and don't hesitate to ask more questions. The more you ask the more you know.