1
I’m trying to run a game I made in Allegro 4, the application only runs normally in the first compilation/execution. If I close Devc++ and open again or try to run the generated . exe file, the game stops working.
After the build the game opens, however it is 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 only using Devc++ because I’m following a Youtube tutorial)
Library: Allegro 4.1
Follow 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.
Very obg for the help Victor. After putting the verification of files in the code, I realized that the game for some reason can not load the images, you know more or less what could be ? The files are already in the folder.
– Igor PTZ
Also, when the code jumps with the drop, the compiler sends three messages and the program fails. Messages are:"crosses boot of MIDI *midi", crosses boot of BITMAP *face and "crosses boot of BITMAP *imagem2"
– Igor PTZ
@Rogi93 Reply edited.
– Victor Stafusa