12.07.2015 Views

Chapter Quiz

Chapter Quiz

Chapter Quiz

SHOW MORE
SHOW LESS
  • No tags were found...

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

304<strong>Chapter</strong> 9 ■Advanced Sprite Programmingint x = startx + (frame % columns) * width;int y = starty + (frame / columns) * height;blit(source,temp,x,y,0,0,width,height);}return temp;void main(void){BITMAP *temp, *buffer;int n;//initializeallegro_init();set_color_depth(16);set_gfx_mode(MODE, WIDTH, HEIGHT, 0, 0);install_keyboard();install_timer();srand(time(NULL));//create second bufferbuffer = create_bitmap(SCREEN_W, SCREEN_H);//load & draw the backgroundback = load_bitmap(“ngc604.bmp”, NULL);stretch_blit(back, buffer, 0, 0, back->w, back->h, 0, 0,SCREEN_W, SCREEN_H);//resize background to fit the variable-size screendestroy_bitmap(back);back = create_bitmap(SCREEN_W,SCREEN_H);blit(buffer,back,0,0,0,0,buffer->w,buffer->h);text_mode(-1);textout(buffer, font, “MultipleSprites Program (ESC to quit)”,0, 0, WHITE);//load 64-frame tiled sprite imagetemp = load_bitmap(“asteroid.bmp”, NULL);for (n=0; n

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!