   Help fixing my code?
  this is allegro:#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 *heroleft = NULL;heroleft = load_bitmap("left.bmp", NULL);BITMAP *heroright = NULL;heroright = load_bitmap("right.bmp", NULL);BITMAP *heroimage = NULL;heroimage = load_bitmap ("right.bmp", NULL); int my_pic_x = 0; int my_pic_y = 0;while(!key[KEY_ESC])//If the user hits escape, quit the program {draw_sprite(screen, heroimage, my_pic_x, my_pic_y); if (key[KEY_LEFT]){heroimage = heroleft;}else if (key[KEY_RIGHT]){heroimage = heroright; }}return 0;}END_OF_MAIN()heres what happens: when i press left the heroleft overlaps heroright, so i can see them both overlapping, and then I press another button and the one on top sort of half moves while the one on bottom just stays there. does anyone know how to fix this? also when i put movement into it it left a "ghost" of the image behind it, if that makes sense, like a streak of its image. someone please help!!!   
  First and foremost, you need to format your code using 'code' tags e.g.,  and .From this bit of code I can't tell you exactly what the overlapping means simply because I don't know what it actually looks like but the 'streaking' your talking about is because you're not 'clearing' the screen between drawing updates.There are two ways to do this: Clear the entire screen by rerendering the entire background (generally slow) or grabbing a portion of the screen underneath your sprite and then before rendering the sprite in a new position draw the portion of background you grabbed and draw it over the first sprite you rendered.;  this is basic but you must understand animation for it to work. When animation is done, on paper you would have many blanks piece of paper to do a page flip. this techinque can be done on the computer but virtually.There is also a techinque just for the computer that saves resources and thats called double buffering. What you do is create an extra surface to render(Draw) to. this extra surface helps illustrate page fliping but loading the next frame and being clear after usage. easy way is to clear the screen but this is slow. The other way is to clear only what needs to be cleared.allegro dont use the concept of surfaces but they are the whole canvas that fills the drawing area. for you that might be the whole screen if in fullscreen mode;  Ok i don't Know Allegro but here is what i can tell you. There is probably a way built into allegro to clear the screen probably through some graphic Variable its worth while to look for it. As for the two solutions leeor_net Describe are quite accurate i will Attempt to explain the easier and slower way but as for performance changes if the game is simple it should not make much of a difference on today's machines if it is even noticeable at all.Here are a few ideas to get you started.if you do find the time to look through the Allegro manual--> http://alleg.sourceforge.net/stabledocs/en/allegro.htmlThe other way would be to do it like this// Create Buffer BitmapBITMAP* buffer = create_bitmap(screen_w, screen_h);// Logic// Drawclear_bitmap(buffer);// Draw Everying to the buffer here// And finally draw the buffer to the screenblit(buffer, screen, 0, 0, 0, 0, screen_w, screen_h);This may work with copy and paste but just to be sure you understand i am going to go over it quickly. First you need to Create a Bitmap. Then we use the clear bitmap function witch gives it data basically makes it a blank bitmap like when you open up a go new file in paint. and last but not least we then render it to the screen.The other option is to grab a bit of the image below the sprite and re-render it when the sprite moves this is a bit of a false truth since you would render all backgrounds before rendering the sprite witch would clear any old sprite data your problem would but that the only thing on the screen is your sprite when you spruce up the background this problem really should not remain. This option is correct give your situation but its not worth the effort in my oppion at least not on today's hardware.Best of luck to youRegards Jouei   