#include <allegro.h>
enum { SUCCESS, FAILURE };
int main(void)
{
//initialization
allegro_init();
set_color_depth(16);
set_gfx_mode(GFX_AUTODETECT, 640, 480, 0, 0);
install_keyboard();
//bitmaps
BITMAP *bmp;
PALETTE palette;
bmp = load_bitmap( "sprite.bmp", palette );
if(!bmp)
{
allegro_message("Error: could not load bitmap");
}
//main game loop
while ( !key[KEY_ESC] )
{
acquire_screen();
draw_sprite( screen, bmp, 20, 20 );
release_screen();
}
return SUCCESS;
}
END_OF_MAIN();
sprite configuration
hey, i just loaded a bitmap onto the screen.well here is the code
but see, problem is, all of the sprite figures show up, i just need to have one static image of the guy, not all his movements
do i need to cut the image out myself or something?
You need to use the blit function for that.
You can specify the frame you want to display by using the position of the sprite within the bitmap as parameter along with the width and height of a single sprite frame.
Look at the documentation for more information.
You can specify the frame you want to display by using the position of the sprite within the bitmap as parameter along with the width and height of a single sprite frame.
Look at the documentation for more information.
The first frame usually is located at (0,0). Where the other frames are depends on the layout of your sprite sheet.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement