Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6533787
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T10:10:14+00:00 2026-05-25T10:10:14+00:00

im trying to make a simple program that has one BITMAP that is the

  • 0

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() 
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T10:10:14+00:00Added an answer on May 25, 2026 at 10:10 am

    The code you have works like this:

    // draw the my_pic sprite to bitty
    draw_sprite(bitty,my_pic,my_pic_x,my_pic_y);
    // status now: bitty contains my_pic
    
    // draw bitty to the screen
    blit(bitty, screen, 0,0,0,0,640,480);
    // status now: screen contains my_pic by way of bitty
    
    // clear bitty
    clear_bitmap(bitty);
    // status now: screen contains my_pic by way of a former
    // version of bitty, bitty is now empty
    
    // draw my_pics to buffer
    draw_sprite(buffer,my_pics,my_pics_x,my_pics_y);
    // status now: screen contains my_pic, bitty is empty,
    // buffer contains my_pics
    
    // draw buffer to the screen
    blit(buffer, screen, 0,0,0,0,640,480);
    // status now: screen and buffer both contain my_pics,
    // bitty is empty
    
    // clear the buffer
    clear_bitmap(buffer);
    // status now:
    //
    //    screen contains my_pics
    //    bitty and buffer are empty
    

    I would imagine you’d want something more like:

    // clear buffer
    clear_bitmap(buffer);
    // status now: buffer is empty
    
    // draw my_pic to buffer
    draw_sprite(buffer,my_pic,my_pic_x,my_pic_y);
    // status now: buffer contains my_pic
    
    // draw my_pics to buffer
    draw_sprite(buffer,my_pics,my_pics_x,my_pics_y);
    // status now: buffer contains my_pic, with my_pics on top
    
    // copy buffer to the screen
    blit(buffer, screen, 0,0,0,0,640,480);
    // status now: buffer and screen contain my_pic, with my_pics on top
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to make a program that takes in one argument, a file, and
I'm new to android and I'm trying to make a simple android program that
i am trying to make a very simple program that invert the pixels position
I'm trying to make a simple program that goes to a page and clicks
I'm new to iPhone programming, and I'm trying to make a simple program without
I'm trying to make a simple blackjack program. Sadly, I'm having problems right off
I'm trying to make a simple C# web server that, at this stage, you
I'm trying to make a program that check the ISBN number and sees if
I am trying to make a simple client-server chat program. On the client side
Hi I'm new to Android Programming and I'm trying to make a simple program

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.