Hot answers tagged

48 votes

How can bays and straits be determined in a procedurally generated map?

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 ...
DMGregory's user avatar
  • 126k
37 votes
Accepted

Best practice for map coordinate system

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 ...
Philipp's user avatar
  • 117k
36 votes
Accepted

From a game design point of view, what are the implications of using realistic distances in an open world map?

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 ...
Philipp's user avatar
  • 117k
30 votes
Accepted

How can bays and straits be determined in a procedurally generated map?

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 ...
Dr. Pain's user avatar
  • 416
18 votes
Accepted

What are good algorithms to generate borders / state areas on 2d star maps?

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 ...
amitp's user avatar
  • 6,026
15 votes
Accepted

How can I generate a (relatively) linear dungeon path?

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 ...
Engineer's user avatar
  • 29.3k
12 votes

Best practice for map coordinate system

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 ...
Alan Wolfe's user avatar
  • 2,363
12 votes

Why are spherical worlds so rare?

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 ...
Philipp's user avatar
  • 117k
11 votes
Accepted

How to use the SDL viewport properly?

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 ...
amitp's user avatar
  • 6,026
11 votes
Accepted

Efficient Algorithm for the boundary of a set of tiles

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 ...
Yakk's user avatar
  • 371
9 votes

Efficient Algorithm for the boundary of a set of tiles

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 ...
DMGregory's user avatar
  • 126k
8 votes
Accepted

How to reference a map position in code?

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 ...
Vaillancourt's user avatar
  • 16.1k
8 votes

From a game design point of view, what are the implications of using realistic distances in an open world map?

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 ...
user3757614's user avatar
7 votes

How to make a map (game world) based on a real world place or city?

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 ...
Philipp's user avatar
  • 117k
7 votes

Efficient Algorithm for the boundary of a set of tiles

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 ...
Theraot's user avatar
  • 22.4k
7 votes

Elegantly transition from 4-grid to 6-grid and back

This is most intuitive way that I can think of.
Shadows In Rain's user avatar
6 votes

zoom to cursor calculation

I couldn't figure out what Konrad's variables were supposed to mean in my game (map width? My map is infinite, so... that's the same as the screen width then maybe? It didn't work out), so I figured ...
Luc's user avatar
  • 175
6 votes
Accepted

Procedural terrain generation in cylindrical (2D) world

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 ...
jgallant's user avatar
  • 8,314
6 votes
Accepted

Finding all hexagonal grid coordinates inside cover arc

I prefer to do hex-cell coordinate math in what Amit calls cubical coordinates on your linked page. For the rest of this answer, (X, Y, Z) will refer to cubical coordinates. Basically, for any of ...
Jimmy's user avatar
  • 9,019
6 votes

How can bays and straits be determined in a procedurally generated map?

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 ...
Autolykos's user avatar
  • 161
5 votes

Map coordinates system

All three uniform 2D grids can be stored in a rectangular grid, you just have to scale and shear it to fit the one you're aiming for. To know what regions you need to load just transform the viewport ...
transistor09's user avatar
5 votes
Accepted

How do I create a custom collision map for clickable areas on a map?

Convert your image to grey-scale. Make sure you have no two states that have the same grey. (You have to tweak the image.) Have an infrastructure that maps the grey colour to a state. Then when you ...
Vaillancourt's user avatar
  • 16.1k
5 votes

Big maps with deep zoom and pan

If you have access to shaders, you can invert the drawing logic. Normally you loop through tiles and draw each one. When you're zoomed out there are a lot of tiles to draw. Zooming out is slower. ...
amitp's user avatar
  • 6,026
5 votes

I need a map generation algorithm for towerdefense

Recently I worked on the map generation algorithm for a tower defense game. The approach I took was to take a maze generation algorithm and use the solution path as the path that creeps follow. This ...
congusbongus's user avatar
  • 14.8k
5 votes

Are huge, static objects like environment transmitted from server to client in modern multiplayer games?

Depends on several factors, including the kind of game (I'll assume RTS here, though open world MMO also comes to mind). A base, local-to-player terrain state is either sent on connect, or is part of ...
Engineer's user avatar
  • 29.3k
4 votes
Accepted

How to design programatically a game map like Risk?

Like @Anko suggested, you should use a graph as data structure for your game map. If you use the this implementation of a graph in Java as a starting point you can represent your map as follows: <...
tryzor's user avatar
  • 156
4 votes

Board like strategy map

Unity is a game development platform that uses languages, such as C# and JavaScript, to create scripts that provide behaviours for elements within your game. If you're creating a 2D top-down game, you ...
driima's user avatar
  • 995
4 votes

Are huge, static objects like environment transmitted from server to client in modern multiplayer games?

As to your exact question as asked, I do not know how League of Legends specifically handles it. I have never played that game, so I cannot suggest whether or not it needs to. But the answer to your ...
Aaron's user avatar
  • 143
4 votes

What are good algorithms to generate borders / state areas on 2d star maps?

One of many methods is an influence map. You can search for specific code implementations, but the basic algorithm is fairly simple. For each faction object (e.g. star system), assign a positive (hot)...
J'Eight's user avatar
  • 41

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