Need Help Making a map

Started by
4 comments, last by CBreinholt 11 years, 8 months ago
Hello! I have been working on some very small projects all of which don't require a map or background image other than a black screen. I am looking to make a pokemon type map where there is a map and buildings and what not and the character stays in the middle at all times. I am using Microsoft Visual C++ and using Allegro 5 with it.

tl:dr Need help starting to make a pokemon type map.

Any and all help is appreciated. I just need a starting point. I will put in all the work I need for the problem solving but I really dont know where to start.

Thanks!
factorXero
Advertisement
Pokemon, or at least older Red, Blue, and Yellow handheld versions, use what's called a 'tile based map'.

Instead of having artists draw huge images of the entire world, which would take ages and waste alot of memory (every single pixel in the world must be saved), the artists draw small "tiles" instead. Tiles are pieces of images that can be recombined and re-arranged by the people making the maps.

A large area like this:
dungeonscene.png

Can be created easily from the separate "tiles".

Here's the scene broken into tiles:
tilegrid.png


That entire map only took 6 tiles to make.
tilesb.png


I explain the basics of how tile maps work here.
Googling "Tile maps C++ Allegro" will probably provide some good tips as well (and perhaps some bad tips as well, but meh - such is the internet).

If you have any questions or need more help, feel free to ask and we'll do our best to help.
To add to what SOTL said:

I had success years ago using a tile map editor called Mappy http://www.tilemap.co.uk/mappy.php with Allegro - there is even a "playback" library you can download that has a minimal tile engine built in.

Note that this was years ago, so I'm not sure which version of Allegro it works directly with, so YMMV.
This goes into more detail about 2D tile maps http://wiki.sheep.art.pl/Tiled%20Map%20in%20PyGame and gives examples . You'll have to translate Python to C++, but it shouldn't be too difficult.

I cannot remember the books I've read any more than the meals I have eaten; even so, they have made me.

~ Ralph Waldo Emerson


Note that this was years ago, so I'm not sure which version of Allegro it works directly with, so YMMV


There are versions of Mappy for all versions of Allegro.
Tiled maps are definitely the way to go for what you're asking. Try something like this:

1) Load the data from a .txt file that looks something like this:

1 1 1 1 1 1 1 1 1 1
1 1 0 0 0 0 0 0 1 1
1 1 0 0 0 0 0 0 1 1
1 1 0 0 0 0 0 0 1 1
1 1 1 1 1 1 1 1 1 1

2) Loop through the data from the .txt file row by row. For each 1, add a wall image, for each 0 add a floor image. Add the image to an array, with each row as its own array. Putting all of the rows in order, and another array. That makes a 2D array which would represent all of the tiles of your map.

3) In your main game loop, loop through your 2D map array, rendering each tile image at the appropriate position. I would even consider going as far as having a tile class, to create tiles for your 2d array that hold not just it's image, but also it's position, weather or not it's a walkable tile, etc. Stuff like that.

That's just a basic idea of what I would recommend, and the above would only display a room, but thats the concept. Tiled maps are actually a lot more simple than people think!

Also if you like the idea of tiled maps, when you become more familiar with them, a really interesting topic is random map generation for generating random dungeons, caves, etc. That way you don't have to load a .txt file, it's all generated. It also give each new map a whole new feel but uses the same tiled map idea. If you're interested at all here is a guide I wrote on 2D tiled random map generation.

http://breinygames.b...generation.html

It would be a pretty cool thing to implement in a pokemon style game. Good luck!

This topic is closed to new replies.

Advertisement