Jump to content
  • Advertisement
Sign in to follow this  

Semi random map

This topic is 2438 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi,

I have broken my head for a while on how i would approach a semi random map generator. What i basically want is a 512*512 map which is pretty open, like diablo above ground. So i thought of dividing this map in 16*16 times 32*32 tile grids. For each of these grids i make a couple of fixed outcomes, just for the shape. So for the corners, sides and the inner pieces i will create binary data or perhaps images. Which leads to my question.

I don't have to create separate grids for each side/corner as i could figure out on which grid the engine is working and put the binary data in reversed for the opposite corner. However this leads to adding extra code for each corner and side, unless there is a way to reverse/rotate/flip the binary file itself. Which opts me for using textures, is it possible to rotate or flip the textures for this purpose, i never used textures for reading this kind of data? How efficient are using textures vs txt files for this purpose?

How would you approach this?

Share this post


Link to post
Share on other sites
Advertisement
I found a nice solution when i was playing around with this idea. I found i can reverse a list to flip it vertically and just throw it to a string reverse function if it needs to be flipped horizontally and do both for the opposite corner. I can also play with this to randomize my level even more.

But still i'm interested in some feedback.

Share this post


Link to post
Share on other sites
Flipping things isn't randomizing things.

If you're trying to make 100% of the tiles in this grid walkable and place walls and obstructions AFTERWARDS, you can give each tile a code for each of its sides, assuming you have different tile types which consist of more than one terrain type each. When you're generating your map, you would check which tiles the current iteration's tile is compatible with, add those to a list or something, then select a random tile from the list to be the next tile in the sequence. You can also give the map's constructor a seed and the class some additional functions to have different outcomes when generating.

If your tiles only use one terrain type, you wouldn't need to use a code system for the edges of the tiles.

If you want the tiles themselves to be walls, doors, corners or hallways in your map, this is where things get a bit more complicated than just generating a walkable landscape. You will probably want to start with an entrance room of sorts, then expand tile by tile. As the constructor iterates through a 2D array or something (or lines in a txt file), you will want to make it check x direction for required space in order to create a new room/hall/door that branches from the first room in x direction. Etc, etc, etc. If there is dead space in your map, you'd want to tell that to the array or txt file and assign dead tiles to a certain txt file character, or None. Or something along those lines.

No code, but I hope this helps.

Also, are you coding in Python?

Share this post


Link to post
Share on other sites
Randomizing by using a computer is not random.

I am making a semi random map, with pre-set grids of 32*32 tiles. I will be making like 10 corners, 10 sides and 20 grids for the pieces inside that 16*16 grid. Then build the map from that, if i can use the flipping on the sides and centre pieces that's more combinations instantly.

This is just to give my 512*512 tilemap a bit of shape, texturing it will be done differently and i will be plopping tree's, buildings (probably pre made too), chests and packs of mobs randomly on the map.

This is just for prototyping and learning purpose as I'm very intrigued by games who use random maps.

Still I'm wondering how diablo does it's above ground randomization. But I'm pretty sure they use pre made grids as well, since all patterns come back each act. While dungeons there are much more different.

I'm using C# and XNA.

Share this post


Link to post
Share on other sites
Well there are a bunch of different ways to do everything. I did not understand what your intent was at first when you spoke about flipping images/tiles. Now I do. And yes, that's a feasible way to obtain more tiles without actually making them in GIMP or whatever. You won't be able to do that with top and bottom corners though, if your game is isometric, unless you plan on creating an illusion that the bottom part of every room will drop off into an endless pit or something.

This guy here's got a pretty nice dungeon randomizer written in python for pygame. If you know the language, look through the code and see how he does it. It's not exactly the same as what you're looking for, but i'm sure you could draw ideas from it.

http://www.gamedev.net/topic/609826-chests-in-random-dungeons/page__p__4856675__fromsearch__1#entry4856675

Share this post


Link to post
Share on other sites
That's actually not what I meant. Let me try to be very clear this time :D.

I have a map that has 512 * 512 tiles. I devide this whole map by 32*32 grids. Then for each grid i make fixed 32*32 maps. For the 4 corners i make 10 32*32 maps, for the sides i make 10 32*32 maps and for the rest i make another 20 maps. Like i said, the maps will be very open, as in most of the inner 32*32 grids will be fully walkable.

I can figure 2 ways for making the 32*32 grids. By text, using just txt now, but since i can't rotate text files i have to make seperate txt files for the top/bottem vs the sides. I can re-use the top grids for the bottom grid and corners since i can flip text files horizontal and vertical by code. Or can I? I could use textures where each pixel represents a tile but since i haven't got any experience with it i don't know if i could rotate and flip such a image for the purpose of orienting a 32*32 grid this way.

This will give me loads of map combinations and with another script to plop tree's, rocks, buildings, chests, etc (some in a sorta same grid style fashion) i get pretty much infinite maps.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!