Hot answers tagged

69

Among the many other related questions on the site, there's an often linked article for map generation: Polygonal Map Generation for Games you can glean some good strategies from that article, but it can't really be used as is. While not a tutorial, there's an article on how Dwarf fortress world maps are generated. Basically you generate multiple layers of ...


67

Here's a quick hack that works with any image editor. If your tile image is called tile.png, create an index.html like this: <body style="background:url(tile.png) repeat 0 0"></body> (Thanks @Deryllium for the simpler alternative!) Open that in a web browser. Whenever you need to check how well the image tiles, save it, and refresh the web ...


53

"Staggered" refers to the jagged edges of isometric maps that have an overall rectangular shape. These maps emphasize the north/south and west/east axes, and often have North up (example: Civilization 2). Diamond maps on the other hand emphasize the diagonal orientation and movement. North is often at the top right (example: Simcity 2000). Also notice the ...


37

Most games place the map origin in a corner. The main reason for this is that tilemaps are often internally stored in two-dimensional arrays, and most programming languages don't allow negative array indexes. There are a lot of discussions about which corner should be the origin, but I don't consider any of the arguments particularly strong. In the end it's ...


34

Your question leads you into the field of procedural content generation. Tile-based world generation derived from continuous/analog methods By continuous, I means something that is not tiles, something that is analog, an example being a vectorised map. You can use any continuous technique for generation, and then quantise it. For example generate a high ...


33

One of the best, and most used, algorithms I've seen out there is generating dungeons using Binary Space Partitioning. The best general explanation I've read is the one found in The Chronicles of Doryen (attached at the end for backup purposes) because explains the procedure without getting into the code, thus leaving the implementation to the reader. Two ...


29

While the other answers here are really good for generating the kinds of static landscapes that would work for this specific need. There are other methods that people coming across this question might be looking for if they want to create landscapes that change over time or appear much more realistic you can follow this technique. Unlike the other answers ...


25

Your RAM is your limit. The following tests were performed on a system with these specs: Intel i5-6600 16 GB RAM NVIDIA GeForce GTX 1070 Windows 7 Home Premium Here is a script I ran which grows a tilemap by filling it with a single tile (32x32 pixels). The Method Grow() adds another column and another row to the current map. The method gets called 100 ...


24

You could use perlin noise, which is normaly used for heightmap generation. Perlin noise in games Then you could use the heights as an adviser, how high the chance of grass/dirt occuring in one region of the map is. Example (Perlin noise values from 0-256): If the value is over 200 the chance that grass is placed is 80% (dirt 20%). If the value is between ...


19

Yes, they use tilemaps (more precisely : small 8x8 hardware tiles). The main reason is that background scrolling and sprites display on most 16-bit consoles are hardware accelerated (there is a dedicated hardware chip for that, VDP in case of genesis). The only way to use that feature on genesis is to divide the background and sprites into small 8x8 tiles (...


19

What you could do is randomly generate a Voronoi map like this: Picking random center points (see the black dots) and randomly decide if they are grass or dirt. Then for over all tiles, check if it's closest to a center point of dirt or a grass. Done! If what you did previously is "flip a coin" for each tile (noise), generating a Voronoi diagram will ...


18

Maybe this is how it's typically done. You have your list of different tiles that represent a road tiles in all their possible orientations. Left to right, all four corners, top to bottom, whatever. Now you'll index all those tiles with a byte each. 8 bits, one for each direction. This could be in a hashmap or by file name... however you want to do this. So ...


18

You can generate the optimal path using A*, then distort it with midpoint displacement. This will ensure your endpoints are met and allow you to control the randomness to a great degree. For example, I would not randomize roads as much as rivers. Whatever intelligence is building roads typically attempts to be optimal about it. Take care to ensure that if ...


18

Using photoshop or GIMP, you can use the offset command. If you are working for say a 100x100px image, you can offset it 50px in each direction, and the seam where the image tiles together will be displayed in the middle of the image. This page has screenshots demonstrating how this works: http://blogs.adobe.com/jkost/2015/01/how-to-create-a-seamless-...


17

TiledMap tiledMap = new TmxMapLoader().load("path/to/tiled/map.tmx"); MapProperties prop = tiledMap.getProperties(); int mapWidth = prop.get("width", Integer.class); int mapHeight = prop.get("height", Integer.class); int tilePixelWidth = prop.get("tilewidth", Integer.class); int tilePixelHeight = prop.get("tileheight", Integer.class); int mapPixelWidth =...


17

Krita has a feature that allows you to edit tiling textures and see the changes update live. By pressing the W key, it enables wrap around mode, which makes this possible. A youtube video of this feature in action is available here. (feature is enabled at 0:12)


15

You can use Perlin Noise for the generation of the terrain, here is how the biomes in Minecraft work. As you can see he uses a heatmap in combination with a rainmap to create the biomes.


15

After banging my head against this problem for a day I found a wonderful tutorial on the very subject over at Sion Dream. I knew there was a way to use object layers! In a nutshell, create an objects layer on your map (Tiled, Tide and the tutorial author's pick, Gleed, all provide this function), draw the shapes you want your Box2d static bodies to be, then ...


15

To get an array with all tiles from a rectangular area of your tilemap, use tilemap.GetTilesBlock(BoundsInt bounds). You will get a one-dimensional array of tiles, so you need to know by yourself when the next row of tiles starts. Any empty cells will be represented with a null value. If you want all tiles, use tilemap.cellBounds. This gets you a BoundsInt ...


14

Short: After completing the shape you should have a multiple of 2 Points for each affected row on your x-axis. From there it becomes just a matter of splitting up these Pairs of Points for each row and then fill the inbetweens. Long1: This is not a complete algorithm. This is just a description of steps to be taken. How to achieve each step is up to the ...


13

Hopefully you have solved this yourself by now, if not here is some help to get you there. Debugger That program you're using to type all your code in to? It's not just for typing code in and pressing "play". It's an IDE (Integrated Development Environment). This means it contains many tools to help you develop, one of those tools is the debugger. I ...


13

Yay I found a research paper! In terms of computational cost Shadow Mapping seems pretty clear winner. Algorithm used can be found here and a C# implementation can be found here, relevant bit below. #region FOV algorithm // Octant data // // \ 1 | 2 / // 8 \ | / 3 // -----+----- // 7 / | \ 4 // / 6 | 5 \ ...


12

Alright, so you're working with two rectangles here. A larger static one (the map) and a smaller moving one (the camera) inside of it. What you want is to not let the bounds of the smaller rectangle move outside the inner bounds of the larger rectangle. // These values likely need to be scaled according to your world coordinates. // The left boundary of ...


12

In theory the location of the origin doesn't matter. All math operations you do when the map is rendered or when objects move on the map work fine regardless of where the origin actually. However in practice there is one reason why you might want to make the center of the map be the origin - and that is limited precision of floating point values. With ...


11

First of all and to clarify, do you require it to be completely top-down or do you consider something like this as being top-down too. In that example you can tell that the house is much taller than the barrel simply by the amount of tiles that they both span vertically. Also, allowing the character to move behind the objects is another good way to let the ...


11

Here is another way to do it with .cellBounds.allPositionsWithin public Tilemap tilemap; public List<Vector3> tileWorldLocations; // Use this for initialization void Start () { tileWorldLocations = new List<Vector3>(); foreach (var pos in tilemap.cellBounds.allPositionsWithin) { Vector3Int localPlace = new Vector3Int(pos....


10

I've used A Bitwise Method For Applying Tilemaps and found it to be a very elegant solution. The article provides a concrete example and discusses how to extend the algorithm to handle multiple terrain types.


9

While I don't know of any truly official convention for classifying these, in the mathematical sense, I'll take Anko's advice and write up what I do know... Amit Patel (Red Blob Games) wrote what I'd consider the definitive guide to using hexagonal grids in games. This guide uses the nomenclature: flat topped pointy topped So while it's not super ...


8

If your argument against an array is "The world will be huge", then it's not about the data-structure, but rather about memory constraints. If your world is so large, that it doesn't fit into memory with a 2D array, then it won't fit into any other data-structure. Instead you would have to implement a (file-)format, that allows loading chunks (or sectors) ...


8

I implemented an entity component framework (similar to Artemis) after I'd already been in development for a while, but I don't think I would have done things differently if starting from a blank slate. I have my world totally separate from the entity framework. It just didn't make sense to me to convert the world into some sort of entity or collection of ...


Only top voted, non community-wiki answers of a minimum length are eligible