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


35

Almost no game uses realistically scaled maps for cities. The problem with creating cities which are even close to the size of real cities is: Maps become difficult for the player to navigate. They can easily get lost. It is very hard to make all of that content interesting. Creating a large amount of good content is time-consuming and draining. So when ...


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


17

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


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


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

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

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

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


8

You've already removed the main negative of a 1:1 scale map by focusing it on a small area instead of an entire city or countryside, but a citadel is still on the large side. The biggest issue here is travel time. Basically, if I want to walk to the store in real life, it might take me 12 minutes (from Google maps). That's alright; a little longer than I ...


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


7

This is most intuitive way that I can think of.


6

A quick and dirty way to identify a separate but connected body of water would be to shrink all water bodies and see if gaps appear. In the example above I think that removing all water tiles which have 2 or less water tiles connected to them (marked red) would provide you with the desirable result plus some edge noise. After you have labeled the bodies, ...


6

As mentioned in the comment, I figured what you required was wrappable noise. With wrappable noise, you can generate seamless textures and game worlds. You are probably familiar with generating 2D noise already. What you need to do is sample 3 dimensional noise instead. Instead of sampling a rectangular shaped noise pattern, you are going to sample a ...


6

Basically, you need to think about what you mean, precisely, by a bay or strait, and why you want to differentiate them (is it for AI calculations, or to label landmarks, or something else?). Play around with a few definitions to find the one that looks best to you. Then, formulate conditions to check on your Voronoi cells. A few suggestions: Bay Any ocean ...


5

What about a grid system centered on the player? That is, just indicate locations as, say, "13 foos south and 6 west of you." That way, you don't need to designate any specific location as the origin. Arrows pointing to nearby interesting things (and more distant bigger things) and giving the distance to them could also help with local navigation, and ...


5

The problem you're asking about is a non-problem, but the structure you've come up with is very inefficient. Consider a simple 128x128x128 chunk. That will require 2097152 instances of Block. You want Block to be as small as possible. One thing that is easy to get rid of is the position. The position is implicit in the array containing the Block ...


5

First, while MMOs usually have a lot of players online at any one time, these players usually concentrate on key-areas. There are usually large parts of the world where no players are present most of the time. That means you can still use chunks and not keep those in memory which have no players near them. When you have some NPCs which need to perform some ...


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