So here is what i have done
I did the basics of c++ and was quite comfortable with them
Now i wanted to start with the allegro gaming library
so i downloaded the library and linked it with my compiler
i compile a program and it compiles fine but when it runs it just displays and blank screen saying windows application at top
What do i do?
Please Help
Here is my code:-

#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;
 
}

Recommended Answers

All 3 Replies

What version of Allegro are you using? That looks like older Allegro code.
Allegro 5 uses a whole new API.
I compiled Allegro 5 on my system using MSYS, MinGW and CMake.
Then I tried compiling that code. Didn't take.
Tried code from the Wiki.
Worked without any problem.

what is msys,mingw,cmake

If you go with Eclipse or NetBeans (and I recommend it), you'll need an external compiler.

MinGW is a GNU C Compiler suite for Windows. And it's pretty sweet.
You can either get the original or TDM-GCC (which is an unintentional pun on "tedium").

MSys is a minimal system which provides a Unix-like environment to compile the code in.
If you want a Make system (you do, but you probably don't know it yet), you want MSys.
If you have external libraries or programs that ask for the "./configure && make && make install" method, you want MSys.
Seriously. You. Want. MSys.

CMake is a program that replaces configure to generate the make files. This is often pretty helpful. You will eventually want this.

All of which are easily googled.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.