2D Game Dev – Part 11.3: Tile Backgrounds with Mappy

This post is a portion of Part 11 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.

We take the tile based background example further with a piece of software called Mappy. This software allows us to easily generate tile maps and then draw them within Allegro 5.

Note: If you are using Allegro 5.01, you will need to download the Mappy software from their website to make maps (though you will still use the .h and .c files attached below in your projects).

Full source can be found here.

Mappy for Allegro 5 can be found here.

Posted in 2D Game Dev, Allegro, C++, Code, Game Dev, Part 11, Tutorial
22 Comments » for 2D Game Dev – Part 11.3: Tile Backgrounds with Mappy
  1. Gautham says:

    Wait wait wait! What about Tiled? :o
    http://www.mapeditor.org/

    I find it much more comfortable than Mappy, but it’s probably personal preference. If you knew about Tiled, I’m curious why you chose Mappy :)

    • Mike says:

      I do like Tiled and feel that it is a very competent map software. The reason I chose Mappy is because they have software developed to interface with Allegro 5 specifically. You can make Tiled maps work with Allegro, but the theme of this series is simplicity. Therefore I chose the simplest software to use. If you know of any software that allows easy Tiled implementation in Allegro 5, let me know and I will gladly make a tutorial out of it.

      • Gautham says:

        You mean Mappy supports Allegro 5 from it’s side? Or do you mean an Allegro extension to parse Mappy files? If you mean the latter, I was thinking of making something myself unless I found aomething similar. (Sorry, I’m still in chapter 3, haven’t watched this video yet >_< )

        • Gautham says:

          nvm. Saw the video and checked out mappy for allegro 5. It’s pretty impressive, really. I won’t be able to write something so elegant any time soon, so I’ll stick to Mappy for now. Thanks for the tutorials :)

  2. Gautham says:

    If you didn’t, I implore you to explore it’s features, it’s just great! :D

    Also, what are your thoughts on making a map editor using Allegro? I ask because my final goal is to make an RPG and I have to deal with this issue eventually. I have an idea of making the maps in Tiled and making an Allegro editor to place interactable and dynamic game objects (because Allegro can be much more aware of them than Tiled). So I make a map in Tiled, load it in the Allegro “object editor” and place objects there.

    PS: Wonderful tutorials btw, really helping. Can’t wait to see it finished. :)

  3. Andrew says:

    I can’t figure out how to use transparent blocks in Mappy.

    I have such a thing: every block with transperency has back background instead of it and my map is so stupid :?

    Could you please add to your tutorials how to work with transparent blocks.

    • Mike says:

      Have you tried this:

      “How does transparency work ?
      and
      Why doesn’t parallax/MapDrawBGT work ?

      This is possibly the most asked question. You nominate a colour to be transparent (usually index 0 in 8bit, some uncommon colour in other depths such as magenta (0xFF00FF)). This is NEVER drawn if the graphic is in the FG1, FG2, FG3 fields of a block structure. If the colour is used in the BG graphic it IS drawn UNLESS the BG Tranparency box is checked in the block properties. The BG Transparency box is the top left box of the ‘Others’, this will be labelled better in later versions of the editor. Make sure you check this box for block 0 if you want BG transparency! The BG transparency only affects drawing in calls to MapDrawBGT. You can check you’ve done it correctly in MappyWin32 by doing an anim preview in the correct colour depth with ‘show background with transparency’ checked and some block other than 0 as the ‘Block Graphic for parallax’. You can also use ‘Autoset BG transparency’ in MapTools. “

  4. Andrew says:

    Thank you for such detailed answer.

    This helped a lot! Half of work i did by my self but with your advice I’ve everything perfect for my RPG background.

    Waiting for your future tutorials. Thanks in advance!

  5. GrygrFlzr says:

    Thank you for the tutorial, but I would have preferred YouTube over Screencast. Other than that I have no problems

  6. AC says:

    Hey Mike,

    I was wondering if you could help me get Mappy up and running? I downloaded your source code but whenever I try to open the application file it tells me that allegro-5.0.2-monolith-md.dll is missing from my computer. Any help would be greatly appreciated

    • GrygrFlzr says:

      Oh that! I had that problem too. Simply copy your allegro-5.0.5-monolith-md.dll (I’m assuming you’re using 5.0.5) to the mappy directory, and rename it to allegro-5.0.2-monolith-md.dll

  7. zac says:

    Hey man nice tutorials…
    I am trying to get collision detection working with something similar to this but using an array of strings and was wondering what the best method to use would be?

  8. mar says:

    how to create parallax using mappy?

  9. Masoman says:

    The video is not working for me right now so I cant check, but is there a way that you can specify what mappy map to load, because I’m trying to code a RPG that uses multiple maps, and I need to specify what map to load on the screen. Also, is there a way that Mappy can tell the code what Item number it used, because some of the tiles have to have collision boxes.
    Great series, keep it going, thanks!!!!

  10. gasdeveloper says:

    I just wanted to let you know about the Mappy_A5 returning 0 for success. It is actually an old C standard that you can find in some other ANSI C libraries. It allows for the functions to return an error number that can also be an enum. Allowing for a bool expression check or for a detailed error number.

    int error = do_something();
    if (error)
    {
    LogError("Something bad happened.");
    do_quit();
    }

    something like that would be the reason it doesn’t return true on success.

    • Mike says:

      Great response! Thanks for the info.

    • gasdeveloper says:


      int error = do_something();
      if (error)
      {
      LogError(error, "Something bad happened.");
      do_quit();
      }

      Sorry, for the semi double post but I forgot something and couldn’t edit my previous post.
      Notice, I added the error variable to the LogError function, because it is an integer, it can be useful to know what failed in the do_something function.

  11. Cody says:

    Sir, I was curious about an algorithm for a zelda-like game, where the tiles sets would scroll once you hit the edge of the zone? I’m having serious issues trying to do this. I’m trying to rework the math you provided, but I must be missing something.

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>

  • Just finished reading "Kingdom Come" by DC comics. Pretty good for a DC book 58 minutes ago
  • This man is my new hero RT @TheKevinDent: Talking to an adult called Tron 4 hours ago
  • "Most importantly I learned you have an amphibious paladin that enjoys ruining people’s day as well as their boats." - Alex 13 hours ago
  • You can strive to be really good at what you do, and one simple assumption comes along and screws everything up. 15 hours ago
  • I think I am going to use the word "chortling" instead of laughing from now on. 1 day ago