开发者

how do you make a background in allegro with c++?

i'm fairly new at programming with allegro, and i wanna change the background color of my programs from something more pleasant than black haha :) can some one help please?

and just for a reference of what im doing

#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 开发者_如何学JAVA= 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();


To create backgroud bitmap try this:

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

then try this to clear bmp to some different color:

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

or this to load bitmap from file:

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

Then you just need to blit this bitmap with your screen - like this:

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


Draw a screen-sized rectangle that is the color you want the background to be. Or just use clear_bitmap to clear the screen.


#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;
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜