Hot answers tagged

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

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 ...


45

"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 ...


28

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 ...


26

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 ...


24

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 ...


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

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 ...


16

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 ...


16

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 ...


16

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: ...


15

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 ...


15

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)


13

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.


12

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 ...


12

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 ...


12

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 \ ...


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 ...


9

There are a few problems to solve here. The first is how to load and unload tiles. The ContentManager by default will not let you unload specific pieces of content. A custom implementation of this, however, will: public class ExclusiveContentManager : ContentManager { public ExclusiveContentManager(IServiceProvider serviceProvider, string ...


9

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 ...


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

An alternatve would be to not place the power-ups near the players but at positions which involve taking some risks to get there. This way you would encourage players to stop hiding which can increase the fun-factor and would reward them for their "courage". On top of that no one could complain that someone was just lucky to pick up a powerful power-up ...


7

Like Byte56 suggested, rather than fix the collision, you simply doesn't allow the collision to happen in the first place. Here's a snippet of how my engine handles it // Reset flags just like you do. this.IsPushingLeft = false; this.IsPushingRight = false; // verticalWall is just a struct containing all the common data for whatever wall of tiles the ...


7

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 ...


7

The answer is simple: a physics engine is not a platformer engine. While you can get kind-of platformer-like behaviour out of a physics engine, you simply do not have enough control to get that really "fluid" gameplay feel of a proper platformer. For example: The classic Mario-style jump requires changing the gravity for the player at different stages of ...


7

You don't need to change the parser, just the renderer. The tiles will be at the 'same' place, except the projection is different. The good news is that the good context 2d can do isometric just by setting the right isometric transform. Once you set it, just draw in a regular way (including drawImage), and all will be drawn in the isometric way !!! magic ...


7

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 ...


7

Here are a few strategies you could try: Precalculate scaled-down versions of your tiles. When you use the full-scale tiles as source and let your engine scale them down everytime it draws them, it needs to perform the interpolation algorithm again and again. But when you precalculate a version of each tile in each zoom-level when you load it, blitting the ...


7

Complete vs. incomplete information What you are looking to do is path finding without complete information. The conceptually sound way to do this would require you to keep track of all of your non-playing character's information state (i.e., the parts of the map they already have discovered). Local information A more workable solution in your case might ...



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