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.
- Part 11.0 – Backgrounds
- Part 11.1 – Parallax Backgrounds
- Part 11.2 – Tile Backgrounds
- Part 11.3 – Tile Backgrounds with Mappy
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.
Wait wait wait! What about Tiled? 😮
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 🙂
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.
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 >_< )
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 🙂
https://github.com/dradtke/allegro_tiled
well it seems that tiled now supports ALLEGRO5 🙂
If you didn’t, I implore you to explore it’s features, it’s just great! 😀
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. 🙂
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.
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. “
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!
Thank you for the tutorial, but I would have preferred YouTube over Screencast. Other than that I have no problems
Sorry, I meant Youtube over Flowplayer.
Whoops. I though all my videos were on youtube. Need to fix that
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
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
I was having the same problem as AC and was wondering what the mappy directory was.
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?
how to create parallax using mappy?
got it
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!!!!
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.
Great response! Thanks for the info.
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.
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.
I know this is like a year old, but in case anyone is searching this in the future and has the same question: This is relatively easy to accomplish. You simply need an if statement. if playerx is within 50px of the edge of the screen (or whatever it is) then update xOff/yOff accordingly. you would want something along the line of the following variables. playerX, playerY, xOff, yOff, mapLeft, mapRight, mapTop, mapDown (For those last 4 variables, it would be the y value that is visible on the screen for the left and right, and the x value that is visible on the screen for the top and bottom. This would be the most math you would need to do). And instead of every step updating xOff/yOff you would update only when mapLeft – playerX < 50 and then you would update xOff/yOff by a large value (to simulate the screen moving to the next area). Sorry if that didn't make a whole lot of sense.
Tiled Map Editor fans should checkout this link – http://usefulgamedev.weebly.com/c-tiled-map-loader.html
Tiled Map outputs the .tmx file which can be parsed using this library.
Great Tutorials!
been doing them the last few days.
But the video on this page doesnt seems to be there. cant find it not even on youtube
Strange. I can see it at the top of the page.
I hate to complain about this because your tutorials are amazing and have helped me a ton but can you please move this video to youtube like the rest of them? 🙂
Hmmm. I thought it was. Let me look into that.
Thank you
hey mike your tuts are unreal man… anyway i created a mappy map and added it in my game (i used mappy help file to get Fg/FFg/FFFg) but i cant find in help how to use the maps tiles as coordinates (i want to make certain tiles “unWalkable” but i have no idea how) have u got much mappy exp. any help would be appreciated ill be goin over the help files again incase i missed anything
Sorry, I don’t do too much with Mappy. Can’t be too much help to you.
aww thats too bad i have a decent looking starter map but my guy just runs over water tiles
There is something that I’m not understanding. In Mike’s tutorial he’s Just executing that algorithm in the ALLEGRO_EVENT_TIMER and printing the map with MapDrawBG, and in his video the map is working just fine, but it doesn’t make sense because, for example, the xOff is being incremented every time you hit RIGHT and the map should be going to the right position and not to the LEFT how’s happening because x is being incremented like all the other positions so all the scrolling should being displayed inverted. Because of it I can’t go into the map if I try re-invert everything the program crashes like shown in the video.
And the more awkward thing is that for testing I downloaded the .cpp file of the tutorial the .fmp file and executing the library mappy_A5 all stuff Mike provided just how is in the video and when I hit LEFT, RIGHT, UP or DOWN is inverted here, probably because of what I said above but in the video is not, is everything right! (Is like the same algorithm is showing different results)
If somebody understood my question, please, answer me what I’m missing what I’m doing wrong.
Hi, i seem to be getting this error when i compile my project
Error 1 error C4996: ‘strcpy’: This function or variable may be unsafe. Consider using strcpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS.
You probably figured it out but I’ll explain in case you haven’t.
> Go to PROJECT
> Click *project name* Properties (at the bottom)
> Click C/C++
> Click Preprocessor
> Click Preprocessor Definitions
> Click Edit
> Then type _CRT_SECURE_NO_WARNINGS
> Click OK
Should fix it 🙂