Hot answers tagged

48

Here's a rough idea using image processing transformations to isolate the features of interest: Apply a flood fill from an ocean cell to make a mask of all ocean cells. Depending on how your rivers are set up, you might need an extra elevation or clearance criterion to keep the ocean mask from flowing inland. ;) Apply a local smoothing to the edge of this ...


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


29

The way Dragons Abound identifies bays is to walk along the coastline and find two spots on the coastline where the straight-line distance between the spots is less than the distance along the coastline between the spots. This is the sinuosity of the coastline between the two spots. By selecting a sinuosity limit and limits for the straight-line distance ...


23

I would go with vertical layout if you are using any sort of bird's eye perspective, as in the image above. Why? Because all walls will be visible. If you use horizontal layout, and you have walls that run along the vertical lines, you will not be able to make out details on them very well (such as doors or gates). Furthermore, if you are using the ...


19

You should use the D* algorithm, which is designed for this exact scenario. Specifically, the D* Lite implementation is the most efficient and simple variant.


17

I think the Voronoi idea is a good one. Each star becomes a seed point for Voronoi, and then the Voronoi regions show the areas owned by each faction. However, there are some changes that will make it work better: As you mentioned, there are empty areas that shouldn't be assigned to a faction. Voronoi will create large polygons that extend out to areas ...


16

Layers are needed not only the most basic use of a tile map, but also allow more artistic expression and play features. Layers define the draw order of the sprites used in your world. They're simply a way to say, "Draw sprite X after sprite Y, so that sprite X will appear on top of sprite Y". They're typically generalized into layers so you don't need to ...


15

Requirements You want multiple paths from A to B. You want to work in grid space, presumably this is tile space for your side-scroller. You don't want paths to cross, or it will spoil game progression. You want the paths to look reasonably organic. Voronoi Diagrams Voronoi Diagrams are space-filling, planar graphs: One nice thing about them is how you ...


13

Have you tried Lloyd's Algorithm? The procedure is pretty simple, and will generate fairly regular looking regions (depending on how many iterations you run). Tile the map with blank hexes to start. Choose N hexes at random. These will represent the "center of mass" for each country. Tag each hex with the center hex it is closest to (Voronoi Diagram). ...


13

You could use OpenStreetMap data. It is liberally licensed. In particular, their wiki says: 3c. If I make something with OSM data, do I now have to apply your license to my whole work? No. For example, if you have written a game or published an artistic map which includes OSM data, only the data is covered by the license. This is called a ...


12

As Martin Sojka notes, rotations are simpler if you convert to a different coordinate system, perform the rotation, then convert back. I use a different coordinate system than Martin does, labeled x,y,z. There's no wobble in this system, and it's useful for lots of hex algorithms. In this system you can rotate the hex around 0,0,0 by “rotating” the ...


12

Okay, for anyone interested in this topic I will now detail the solution I have chosen. Thanks to every one who replied and gave me ideas. First, for the 'best' tesselation, I will choose the truncated icosahedron as a starting point. Subdividing it leads to a very nice tesselation of hexagons with 12 pentagons providing the curvature. Also, continuing the ...


12

In doing a similar project, I found the SketchUp modeling program to be excellent for copying existing architecture. That's what Google originally meant it for after all. Here's an account of how I did this: Outsides SketchUp's Photo Match feature (tutorial video) is an absolute killer. It lets you to do this: Load in a photograph of the real building ...


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


12

Because spherical maps, compared to rectangular ones, create a lot of additional complexities regarding the technical implementation and the UI design while usually offering very little gameplay advantage. First, there is the technical problem. With a rectangular map, you just use a 2-dimensional array to represent map positions. But unfortunately there is ...


11

My guess is you're trying to implement a camera, and should not be using SDL Viewports. The viewports are for UI elements like menus, minimaps, etc. It's a way of dividing up the screen into multiple areas. To implement a camera, you will want to think about coordinate systems. The world coordinates are the positions in the world, without thinking about the ...


11

Finding an algorithm is usually best done with a data structure that makes the algorithm easy. In this case, your territory. The territory should be an unordered (O(1) hash) set of borders and elements. Whenever you add an element to the territory, you iterate over adjacent tiles and see if they should be a border tile; in this case, they are a border ...


10

I think it helps to compare it side-by-side with regular Perlin noise. As explained in the Gustavson paper, Perlin noise works by assigning pseudo-random values (gradient vectors) to each corner of a square grid and then doing some interpolation for points in the interior of a grid cell. So the first step in evaluating Perlin noise is to figure out which ...


10

What you're describing is the Segmentation Problem. I'm sorry to say that it's actually an unsolved problem. But one method I would recommend for this is a Graph-Cut based algorithm. Graph-Cut represents the image as a graph of locally connected nodes. It subdivides connected components of the graph recursively such that the border between the two sub-...


9

Check out Amit Patel's excellent article that I feel is kind of a quintessential resource for procedural generation of terrain... http://www-cs-students.stanford.edu/~amitp/game-programming/polygon-map-generation/ The key thing he does is use graph structure to model his terrain, not straight up noise maps (Perlin et al). I won't embed his illustrations, ...


9

If you need to find edges of holes in the middle of your territory too, then your linear in the area of the territory bound is the best we can do. Any tile on the interior could potentially be a hole that we need to count, so we need to look at every tile in the area bounded by the territory's outline at least once to be sure we've found all the holes. But ...


8

I recommend Natural Earth Data as a source of public domain cultural and physical GIS data with global coverage. Vector data sets include landmasses, countries, populated places etc, while raster base layers are available with optional details like land elevation, climate, waterways and submarine elevation. This data is intended for use with GIS software, ...


8

I would suggest you start by building a node graph (a bunch of nodes and arcs (sometimes called edges)). The nodes are the cities and "dash" intersection The arcs link cities and "dash" intersection Then all these nodes have info like their 'physical' location (x/y coordinates on the map). To solve your issues: you use the position that are set in the ...


8

Here is the map of Chicago from Watch_Dogs: And here is the map of Chicago from Google Maps: As you see, these maps don't have much in common. When seen from a birds-eye perspective there isn't even a superfluous similarity. You will also notice that the map from Watch_Dogs is tiny compared to real-world Chicago. Actually, Watch_Dogs Chicago has barely the ...


7

There is a way to do this rather elegantly based on subdividing an icosahedron, as you suggested in your question. An icosahedron is made of 20 equilateral triangles, and these triangles can be grouped into 5 sets, where the 4 triangles in a set form a parallelogram shape: (The groups of four triangles with a squiggle drawn through them are the ...


7

Notice: Whether or not a tile is on the boundary only depends on it and its neighbors. Because of that: It is easy to run this query lazily. For instance: You do not need to search for the boundary on the whole map, only on what is visible. It is easy to run this query in parallel. In fact, I could image some shader code that does this. And if you need it ...


6

You want to go from a planar world, to a cylindrical one. A rotation around the x axis (in homogeneous coordinates) looks like this: | 1 0 0 0 | Rx = | 0 ca -sa 0 | | 0 sa ca 0 | | 0 0 0 1 | Where: ca = cos(angle) and sa = sin(angle) To calculate the angle, look at the image. The pi/2 cancels out and you are left with: ...


6

I was experimenting a bit after playing Deathspank, which has a similar effect. Though I never delved into it enough to see if it could be tuned to work super well, one possibility is to just modify items in your vertex shader based on depth. A function mapping cos(depth) to a Y axis modification works. You can adjust it such that the world not only drops ...


6

The edges of a graph are implicit; they are defined by each node's adjacency list. If node A has both node B and C registered as adjacent nodes, but only node B has A registered as an adjacent node, then the edge between nodes A and C is implicitly directed towards C. Nodes can be implemented as a collection of its adjacent nodes and its data (position ...


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