如何用C++制作快板背景?

如何用C++制作快板背景?,c++,background,allegro,C++,Background,Allegro,我对allegro编程相当陌生,我想把我的程序背景颜色从比黑色更令人愉快的颜色改过来。哈哈:有人能帮我吗 作为我所做工作的参考 #include <allegro.h> BITMAP* buffer; BITMAP* bmp; int cursor_x = 20; int cursor_y = 20; int getMouseInfo(){ if(mouse_b & 1){ cursor_x = mouse_x;

我对allegro编程相当陌生,我想把我的程序背景颜色从比黑色更令人愉快的颜色改过来。哈哈:有人能帮我吗

作为我所做工作的参考

#include <allegro.h>

BITMAP* buffer;
BITMAP* bmp;
int cursor_x = 20;
int cursor_y = 20;

int getMouseInfo(){
     if(mouse_b & 1){
                  cursor_x = mouse_x;
                  cursor_y = mouse_y;
      return 1;
     }
  return 0;
}
void updateScreen(){

     show_mouse(NULL);
     circlefill ( buffer, cursor_x, cursor_y, 60, makecol( 0, 255 , 0));
     draw_sprite( screen, buffer, 0, 0);  
}
int main(){

    allegro_init();
    install_mouse();
    install_keyboard();
    set_color_depth(16);
    set_gfx_mode( GFX_AUTODETECT, 640, 480, 0, 0);
    rectfill (  

    buffer = create_bitmap( 640, 480);     


    show_mouse(screen);        

    while( !key[KEY_ESC])
 {
  int switcher=1;
  while(getMouseInfo()) 
  { 
   updateScreen();
   if(getMouseInfo()==0) switcher=0;
  }
  if(switcher==0) show_mouse(screen);

    }

 return 0; 
}
END_OF_MAIN();

绘制一个屏幕大小的矩形,它是您希望背景的颜色。或者只需使用clear_bitmap清除屏幕。

要创建背景位图,请尝试以下操作:

/* Make a bitmap in RAM. */
  BITMAP *bmp = create_bitmap(SCR_X, SCR_Y);
然后尝试将bmp清除为其他颜色:

或通过以下方法从文件加载位图:

bmp = load_bitmap("image.pcx", palette);
然后,您只需在屏幕上闪烁此位图-如下所示:

  /* Blit bmp on the screen. */
  blit(bmp, screen, 0, 0, 0, 0, bmp->w, bmp->h);

是的,我希望我不必在Allegro 4中绘制一个矩形,你通常会使用你创建的屏幕外位图缓冲区。最终你会发现每一帧你都需要清除它并重新绘制帧。。。因此,除了将其清除为黑色之外,没有额外的工作。clear\u bitmapbmp是对clear\u to\u colorbmp、makecol0、0、0的同义调用。正在调用clear\u to\u color。。。就在清除\u bmp之后。。。这是一种浪费。只需呼叫clear_to_color。。。。另外,只需调用BITMAP*bmp=load_bitmapimage.pcx,调色板,您不需要首先在RAM中创建位图。
  /* Blit bmp on the screen. */
  blit(bmp, screen, 0, 0, 0, 0, bmp->w, bmp->h);
#include <iostream>
using namespace std;

int main()
{
    cout<<" In the world were gamers play MINECRAFT, where they creating everithing they   can emagine ...\n";
    cin.get();

    return 0;
}