0

I am trying to create a program using allegro 4 to load a few images for creating a space invaders User interface.

#include <allegro.h>

int main(void)
{
    char *filename = "ship.gif";
    BITMAP *image;
    int ret;

allegro_init(); 
install_keyboard(); 
set_color_depth(16);

ret = set_gfx_mode(GFX_AUTODETECT_WINDOWED, 640, 480, 0, 0);
if (ret != 0) {
    allegro_message(allegro_error);
    return 1;
}

//load the image file
image = load_bitmap(filename, NULL);

if (!image) {
    set_gfx_mode(GFX_TEXT, 0, 0, 0, 0);
    allegro_message("Error loading %s", filename);
    return 1;
}

//display the image
blit(image, screen, 0, 0, 0, 0, SCREEN_W, SCREEN_H);

//done drawing--delete bitmap from memory
destroy_bitmap(image);
//display video mode information
textprintf_ex(screen,font,0,0,1,-1,"%dx%d",SCREEN_W,SCREEN_H);

while (!keypressed());

//exit program
allegro_exit();
return 0;
}

END_OF_MAIN()

This is my code and i am trying to load a few images to form a space invaders User interface..When i run it , it show error loading ship.gif..Can anyone help with this ?

1 Answer 1

0

Allegro 4 doesn't support loading gif images. You'll need something like this:

http://algif.sourceforge.net/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.