Full screen blackout using allegro in codeblocks
Posted
by
Armando Ortiz
on Game Development
See other posts from Game Development
or by Armando Ortiz
Published on 2012-11-21T02:27:10Z
Indexed on
2012/11/21
5:22 UTC
Read the original article
Hit count: 333
I'm very interested in game programming and I'm taking my first steps alone. So I installed allegro. Although Dev-C++ didn't work, Code::Blocks compiled successfully. I started out with this basic program:
#include <allegro.h>
int main(){
allegro_init();
install_keyboard();
set_gfx_mode( GFX_AUTODETECT, 640, 480, 0, 0);
readkey();
return 0;
}
END_OF_MAIN();
The problem comes in when I try to run it. It opens the little window as always, but rapidly blacks out my whole screen. I press any key and it takes me back to the little window telling me that it finished, which means the program worked. But I try any other program with allegro, like:
#include <allegro.h>
int x = 10;
int y = 10;
int main(){
allegro_init();
install_keyboard();
set_gfx_mode( GFX_AUTODETECT, 640, 480, 0, 0);
while ( !key[KEY_ESC] ){
clear_keybuf();
acquire_screen();
textout_ex( screen, font, " ", x, y, makecol( 0, 0, 0), makecol( 0, 0, 0) );
if (key[KEY_UP]) --y;
else if (key[KEY_DOWN]) ++y;
else if (key[KEY_RIGHT]) ++x;
else if (key[KEY_LEFT]) --x;
textout_ex( screen, font, "@", x, y, makecol( 255, 0, 0), makecol( 0, 0, 0) );
release_screen();
rest(50);
}
return 0;
}
END_OF_MAIN();
And the same thing happens over and over again! Is there something I'm doing wrong?
© Game Development or respective owner