I'm trying to run a game I made in Allegro 4, the application only runs normally on first compilation / execution. If I close DevC ++ and re-open or try to run the generated .exe file, the game stops working.
After compiling the game opens, but gets minimized and locked in the taskbar, the only way to close it is through the task manager.
I noticed that this problem appeared after adding sound to the game.
Information:
System: Windows 7 Professional
IDE: DevC ++ 4.9.9.3 (I'm just using DevC ++ because I'm following a YouTube tutorial)
Library: Allegro 4.1
Here is the code below:
#include <allegro.h>
int main(){
// Inicialização
allegro_init();
install_keyboard();
set_color_depth(32);
set_window_title("The Emoji 2");
install_sound(DIGI_AUTODETECT,MIDI_AUTODETECT,NULL);
set_gfx_mode(GFX_AUTODETECT_WINDOWED,800,600,0,0);
// Variáveis
int x = 100;
int y = 100;
// Imagens
BITMAP *buffer = create_bitmap(800,600);
BITMAP *imagem1 = load_bitmap("Emoji1.bmp",NULL);
BITMAP *imagem2 = load_bitmap("Emoji2.bmp",NULL);
BITMAP *face = load_bitmap("Emoji1.bmp",NULL);
// Sons
MIDI *midi = load_midi("midi.mid");
play_midi(midi,TRUE);
while(!key[KEY_ESC]){
if(key[KEY_RIGHT]){
x += 1;
face = imagem2;
}
else if(key[KEY_LEFT]){
x -= 1;
face = imagem1;
}
else if(key[KEY_UP]){
y -= 1;
}
else if(key[KEY_DOWN]){
y += 1;
}
draw_sprite(buffer,face, 100 + x, 100 + y);
draw_sprite(screen,buffer, 0, 0);
rest(5);
clear(buffer);
} // fim do while
destroy_bitmap(buffer);
destroy_bitmap(face);
destroy_bitmap(imagem1);
destroy_bitmap(imagem2);
destroy_midi(midi);
return 0;
}
END_OF_MAIN()
Note: The files called in the code are already inside the project folder.