double buffering - Allegro, sprites leaving trail -


i'm getting problem sprites leave trail behind when move them. tried drawning bg every refresh start flickering.

this do

// ...  int main(int argc, char *argv[]) {     bitmap *buffer = null;      bitmap *graphics = null;      buffer = create_bitmap(screen_w, screen_h);      graphics = load_bitmap("my_graphics.bmp", null);          clear_to_color(screen, makecol(0, 0, 0));      clear_to_color(buffer, makecol(0, 0, 0));      while(!key[key_esc])      {          // ...          render_map(100,100);                  // ...     } }  void render_map(int w, int h)  {     // ...      for(int i=0;i < w * h;i++)      {         masked_blit(graphics, buffer, 0, 0, pos_x, pos_y, 32, 32);       }      // ...         blit(buffer, screen, camera_x,camera_y,0,0,screen_w, screen_h);      clear_to_color(buffer, makecol(0, 0, 0));  } 

thanks in advance help

your code little hard read, , you've left out big pieces of it. it's hard sure, line looks suspicious:

blit(buffer, screen, camera_x,camera_y,0,0,screen_w, screen_h); 

when using buffer, typically calling like:

blit(buffer, screen, 0,0, 0,0, screen_w,screen_h); 

and only time ever draw screen. steps are:

  1. clear buffer (by drawing background image, tileset, color, etc)
  2. draw buffer
  3. copy buffer screen
  4. repeat

Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -