2D Game Dev – Part 1.2: Your First Allegro 5 Program

This post is a portion of Part 1 in my on going series about 2D Game Development using the Allegro 5 library. These posts are in course order. You can see all of the posts in this course by clicking the “2D Game Development” button at the top of this site.



In this video, we are looking at testing the installation we did in the previous section. I walk you through a simple application to compile and make sure everything is working.

In Part 2 we will be looking at getting into the world of 2D games.

Full source can be downloaded here.

Posted in 2D Game Dev, Allegro, C++, Code, Game Dev, Part 1, Tutorial
24 Comments » for 2D Game Dev – Part 1.2: Your First Allegro 5 Program
  1. Hi mate,
    After doing all of the above following steps, and double checking that I have installed it correctly I am still getting the error after the end of this tutorial

    1>—— Build started: Project: Alegro Test, Configuration: Debug Win32 ——
    1> main.cpp
    1>c:userssoxdocumentsvisual studio 2010projectsalegro testalegro testmain.cpp(1): fatal error C1083: Cannot open include file: ‘allego5allegro.h’: No such file or directory
    ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

    Any suggestions?

  2. sjackm says:

    Well, I tried making this under Code::Blocks after following a long and tiring configuration tutorial on their site, but it fails to compile.

    It says that I’m giving too many arguments to the “al_show_native_message_box” function.

    Also, I observed that you got this neat feature: when you type an include, or a function, some auto-complete pops up showing similar named functions. Is this only a Microsoft Visual Studio specific feature, or can I get it to work on Code::Blocks too? Because certain things appear to pop-up in Code::Blocks, but not allegro functions. It would be a great help for a newbie like me.

  3. sjackm says:

    Well, unfortunately that is one tutorial I’ve followed in the past, but now it’s useless because the 5.0.4 binaries are pre-compiled. There’s no point to struggle with compiling myself the source code.
    The one I followed should work just fine but it doesn’t :( . This takes away of my enthusiasm :( .

    • Mike Geig says:

      Mind posting some of your code? What happens if you remove that command? Does the rest of the program function?

  4. sjackm says:

    It’s exactly the same code like in your “Your First Allegro 5 Program” tutorial, except that I added all these things “#include

    #define ALLEGRO_STATICLINK
    #include “allegro5/allegro.h”
    #include “allegro5/allegro_font.h”
    #include “allegro5/allegro_ttf.h”
    #include “allegro5/allegro_image.h”
    #include “allegro5/allegro_primitives.h”
    #include ”

    before the int main.
    It warns be that I am converting to non-pointer type ‘int’ from null, and then it says that I give the al_show_native_message_box function too many argments.

  5. sjackm says:

    Haha, thanks. That solved the problem. Now I can follow your tutorials. Again, it’s late and I will leave that for tomorrow. One question though, for each new Allegro 5 project, do I have to remake the linker configurations?(manually add the libraries each time). Is there an “preset” option or something like that?

  6. aaa111 says:

    Very nice tutorial. Is there any plan for a text format of the tutorial? I like to reading tutorials rather than watching them.

    • Mike says:

      I have no plans at this time to make a text version. I just don’t have the time to do it. If someone else would like to, I would be more than happy to host

  7. Erik says:

    Mike, do you know how to apply the same debugging settings to multiple projects? Specifically I want to set the same environment variable in “Configuration Properties -> Debugging” in multiple projects within a solution. Loading/saving Property Sheets from the Property Manager does not seem to affect the Debugging settings, only the General, C/C++, Linker settings etc.

    There does not seem to be a way of saving and applying Debugging settings to other projects… Any ideas?

  8. Nathan says:

    when i run my program it tells me there was build errors

    1>—— Build started: Project: allegrotest, Configuration: Debug Win32 ——
    1> main.cpp
    1>d:\users\hodgen\desktop\c++\allegrotest\allegrotest\main.cpp(21): error C2059: syntax error : ‘)’
    ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

    • Mike says:

      I have faith that you can figure this one out. My instincts are telling me something strong about line 21… maybe an extra parenthesis.

      • Nathan says:

        for some reason it worked when i copied into another project, there shuold be a black box that pops up for a second right?

  9. Andy says:

    Just for convenience, I am following your tut with Allegro 5.0.5, MingW 4.5.2 and Code::Blocks.

    I’d like to give a heads-up against keeping all those NULL in the call to al_show_native_message_box agruments…in my trials this prevents ANY text (also the ones we are typing there to inform about initialization problems) to show up, so you get a perfetcly empty dialog box..providing at least Window Title lets the message show up correctly.

    I don’t know if thisi s a bug in Allegro call or not but I am about to file a one in Allegro BugTracker.

    It could also be nice to pass ALLEGRO_MESSAGEBOX_ERROR as a flags paramenter instead of a NULL pointer, since then you geta “error” kind of dialog instead of the “information” one.

    nothing really important but maybe useful to know.

  10. Locky says:

    hey, i tryed to run the code in your tutorial but when ever i do it says:

    unable to start the program Ç:\users\locky\documents\Visual Studio 2010\Projects\Allegro Test 1\Debug\Allegro Test.exe’.

    The system can not find the file specified.

    any ideas? i think i may have moved one of the files somewhere and now im not sure what to do.

  11. swapnil says:

    hey mike i am also getting the same error as Locky here..whenever i compile it says
    it cant find the file specified.i double checked the executable location..everything is perfect.but i am getting the same error message..plz help

    • Mike says:

      Where is your project set to place the output? You may want to check that or start a new project and try it.

      • swapnil says:

        thanxs mike!!! i rechecked the file location and there was an error..and did two different things…instead of copying include and lib folder into msvc 2010′s respective include and lib folders,,,i copied the address of allegro’s include and lib in my project properties tab under :C\C++->General->Additional include directories and Linker->General->Additional Lirary directories….while Linker->Input->Additional Dependencies is the same i.e.allegro-5.0.6-monolith-md-debug.lib…(i using 5.0.6 version).
        i wanna know what i did is just an alternate path or the same thing.?thanxs again for ur great work sir..

1 Pings/Trackbacks for "2D Game Dev – Part 1.2: Your First Allegro 5 Program"

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>