12.07.2015 Views

Chapter Quiz

Chapter Quiz

Chapter Quiz

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

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

316<strong>Chapter</strong> 9 ■Advanced Sprite ProgrammingThen skip down past erasesprite, updatesprite, and warpsprite, and you’ll see therle_grabframe function. I have converted it to compiled_grabframe, and it looks like the following.(The changes are in bold.)COMPILED_SPRITE *compiled_grabframe(BITMAP *source,int width, int height,int startx, int starty,int columns, int frame){COMPILED_SPRITE *sprite;BITMAP *temp = create_bitmap(width,height);int x = startx + (frame % columns) * width;int y = starty + (frame / columns) * height;blit(source,temp,x,y,0,0,width,height);//remember FALSE is always used in second parametersprite = get_compiled_sprite(temp, FALSE);}destroy_bitmap(temp);return sprite;Moving along to the main function, you change the title.textout(screen, font, “CompiledSprites Program (ESC to quit)”,0, 0, WHITE);Cruising further into the main function, make a change to the code that loads the dragonsprite images.//load compiled sprite of dragontemp = load_bitmap(“dragon.bmp”, NULL);for (n=0; ncurframe],dragon->x, dragon->y);release_screen();

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

Saved successfully!

Ooh no, something went wrong!