Olá, estou com problemas na compilação de um código C com a biblioteca do Allegro na versão 4. Estava assistindo a um tutorial para reescrever o jogo space invaders e sempre que compilo o code::blocks abre o programa mas logo fecha e uma mensagem de erro aparece na segunda tela: "shutting down allegro due to signal #11 segmentation fault (core dumped)".
o código é o que se segue:
#include <allegro.h>
void sair();
int sai = 0, width = 740, height = 740;
struct obj {
int x;
int y;
int wx;
int wy;
int w;
int h;
}invader[5][10];
int main() {
allegro_init();
install_keyboard();
set_color_depth(32);
set_window_title("space invaders");
set_close_button_callback(sair);
set_gfx_mode(GFX_AUTODETECT_WINDOWED, width, height, 0, 0);
BITMAP *buffer = create_bitmap(width, height);
BITMAP *fundo = load_bitmap("img/fundo.bmp", NULL);
BITMAP *invad = load_bitmap("img/invasores.bmp", NULL);
for(int i = 0; i < 10; i++) {
for(int j = 0; j < 10; j++) {
invader[j][i].x = 42;
invader[j][i].y = 313;
invader[j][i].wx = 42;
invader[j][i].wy = 313;
invader[j][i].w = 40;
invader[j][i].h = 30;
}
}
while (!(sai || key[KEY_ESC])) {
draw_sprite(buffer, fundo, 0, 0);
for(int i = 0; i < 5; i++) {
for(int j = 0; j < 10; j++) {
masked_blit(invad, buffer, invader[j][i].x, invader[j][i].y, invader[j][i].wx, invader[j][i].wy, invader[j][i].w, invader[j][i].h);
}
}
draw_sprite(screen, buffer, 0, 0);
draw_sprite(invad, fundo, 0, 0);
rest(30);
clear(buffer);
clear(invad);
clear(fundo);
}
destroy_bitmap(buffer);
return 0;
}
END_OF_MAIN();
void sair(){sai = 1;}
END_OF_FUNCTION(sair);
Se alguém puder por favor me ajudar o porquê disso estar acontecendo, eu agradeceria muito mesmo.