1

我在使用 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();
4

3 回答 3

2

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

/* Make a bitmap in RAM. */
  BITMAP *bmp = create_bitmap(SCR_X, SCR_Y);

然后尝试将 bmp 清除为某种不同的颜色:

  /* Clear the screen to red. */
  clear_to_color(bmp, makecol(255, 0, 0));

或者从文件中加载位图:

bmp = load_bitmap("image.pcx", palette);

然后你只需要用你的屏幕来blit这个位图——像这样:

  /* Blit bmp on the screen. */
  blit(bmp, screen, 0, 0, 0, 0, bmp->w, bmp->h);
于 2011-07-09T09:20:01.577 回答
0

绘制一个屏幕大小的矩形,它是您想要的背景颜色。或者只是用于clear_bitmap清除屏幕。

于 2011-07-09T04:35:06.427 回答
-3
#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;
}
于 2014-03-22T18:36:29.647 回答