# Tag Info

66

You need to change the shape of the field of view. So that when you move in any direction, the same number of new squares become visible. Here is one possibility:

66

Dungeons and Dragons 3.5 (pen-and-paper RPG) has a solution used for both movement and grid-based radius calculations: diagonal movement costs 1.5 what orthogonal costs. Since the diagonal of a unit square is approximately 1.414, 1.5 is pretty close. Because D&D 3.5 only supports integer movement, the way this is actually calculated is that orthogonal ...

59

Octogons: Hexagons: The gaps in the octogons make for an unappealing game world. Typically, if you wanted to allow for eight directions of movement, you would just use squares.

51

To summarize and elaborate upon what has been said in other answers and in comments, triangles, squares and hexagons are the only mathematically possible regular tilings aka regular tessellations of the Euclidean plane. So yeah, this sucks. Triangles are completely useless here, squares suck because you can't move diagonally without having a somewhat ...

27

This guide didn't exist when the question was asked, but here's my guide to hex grid math: Hexagonal Grids

26

To have diagonal and orthogonal movement reveal approximately the same area, you need two things (each of which, alone, has already been suggested in another answer or comment): Approximately circular view range: On its own, this won't give exactly the same revealed area for both types of movement. For example, in the image above, orthogonal movement ...

21

The author of HyperRogue here. HyperRogue actually uses a tesselation made of hexagons and heptagons, here is the reason why this particular tesselation has been chosen, instead of only octagons or heptagons, for example: Hyperbolic geometry in Hyperbolic Rogue Basically, the octagons are too big. Also some consequences of using hyperbolic geometry in a ...

19

I created a system similar to the one you're after in 3D. I have a short video demonstrating the simple mechanics of it here and a blog post here. Here's a little gif I made of the pressure mechanics behind an invisible wall (played at high speed): Let me explain the data involved, to give an idea of some of the features of the system. In the current ...

17

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

17

A hexagonal ring with the radius of N consists of 6 straight lines, each with length N - see my extremely crude example below :) For N=2: The arrows cover 2 hexes each. I assume you have some functions which give you the neighbouring tile in a specific direction, like north(), southeast() etc. So your algorithm, in pseudocode, should be something like ...

16

I have been working on a hex tile game and found these tutorials useful: Coordinates in Hexagon-Based Tile Maps Isometric 'n Hexogonal Maps Part I Isometric 'n Hexogonal Maps Part II Drawing a Hex Grid in Illustrator (for designing maps) Good luck with your project!

14

getBodiesToCheck() There could be two problems with the getBodiesToCheck() function; first: if(!contains(bodiesToCheck, b)) bodiesToCheck.push_back(b); This part is O(n2) isn't it? Rather than checking to see if the body is already in the list, use painting instead. loop_count++; if(!loop_count) { // if loop_count can wrap, // you just need to ...

12

There's a number of pieces to this puzzle, each of which will provide a deep and interesting rabbit hole of exploration. Some of them are: Level of Detail -- automatically (or "manually") choosing detailed or simplified models, or even sprites or just dots, or for objects as they are further away. Culling -- choosing to only draw what's needed. This might ...

11

Since you are using a grid and know which direction the user is proceeding there is nothing constraining you from adapting the prior answer and using a different fields of view depending on the direction. For example you could extended the field to include the corners when you travel in cardinal directions and shrink it down two squares on each end in your ...

10

You can do something like this int gridCubeWidth = 16, gridCubeHeight = 16; cube.Position.X = Math.Floor(cube.Position.X / gridCubeWidth) * gridCubeWidth; cube.Position.Y = Math.Floor(cube.Position.Y / gridCubeHeight) * gridCubeHeight; This basically rounds the X and Y positions to the nearest multiple of the cube dimensions. Then scales it by the cube ...

9

Fascinating question. I think one of the first issues you have to address is whether you want the patrolling behavior to be "optimum" patrolling or "lifelike" patrolling. I'm just making up these words, but what I mean is: Optimum: The agents move about in a manner that perfectly distributes their coverage area for the system as a whole. Lifelike: The ...

9

Basically what you want is a monohedral tesselation (or tiling), that is a coverage of the entire plane (assuming 2d) with a single shape where the tiles do neither overlap nor leave gaps. There are lots of shapes with which this can be done but when we introduce other constraints, usually orientation should stay the same or they should conform to a ...

8

Sounds like you want A-star path-finding, which is pretty much the defacto for path-finding. I used this in my XNA game: http://www.csharpcity.com/reusable-code/a-path-finding-library/ (I repackaged the library into a slightly more usable stand-alone DLL).

8

There are many ways to go depending on exactly how you want it. Here is a rough outline of one way which I think will fit your description: First generate the canals. Then start placing houses randomly, for each house you place, place the road in front of it and draw a road from that piece to the existing road network, if either is not possible or placing ...

8

Such a bijective mapping is much easier to express if your tile indices and rows/columns are zero-based. col: 0 1 2 3 [ 0 1 2 3 // row 0 4 5 6 7 // row 1 8 9 10 11 // row 2 12 13 14 15 // row 3 ... If you look at the column numbers, as the column number increases by one, so does the tile index. More particularly, there's ...

8

Before I answer the question you already asked, some notes: You can use A* with the original grid system you are using. The key things you need are neighbors and distance (for the heuristic). For neighbors with your grid system, you need to do something different for even and odd columns (as you mention); here's how: neighbors = [ [ [+1, +1], [+1, 0]...

8

I'd consider a Square-based grid as a "base" type of tiles in any game. Such grid is simple to imagine and moves over this grid are simple to understand. It's also very simple to implement "under the hood". Those are few reasons why even the Chess game uses it :). Additionally, this grid helps you make "regular" levels, because Vertical and Horizontal are ...

8

You are looking for a grid traversal algorithm. This paper gives a good implementation; Here's the basic implementation in 2D found on the paper: loop { if(tMaxX < tMaxY) { tMaxX= tMaxX + tDeltaX; X= X + stepX; } else { tMaxY= tMaxY + tDeltaY; Y= Y + stepY; } NextVoxel(X,Y); } There's also a 3D ray-...

8

X = x*cos(θ) - y*sin(θ) Y = x*sin(θ) + y*cos(θ) This will give you the location of a point rotated θ degrees around the origin. Since the corners of the square are rotated around the center of the square and not the origin, a couple of steps need to be added to be able to use this formula. First you need to set the point relative to the origin. Then you ...

7

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

7

This is a form of the Packing Problem. Here are your options: Brute force it as Gajet has mentioned. This can be aided by doing a pre-evaluation of existing space in your world grid, so as to find maximal axis-aligned bounding boxes. This article should give you some insight into how one developer applied solutions to the Packing Problem, in regards to ...

7

Judging from a quick look at the libgdx wiki's SpriteBatch entry, alpha blending is on by default. Blending is enabled by default. This means that when a texture is drawn, translucent portions of the texture are merged with pixels already on the screen at that location. This means that you can do what you said: open the Hero texture in Paint .NET and "...

7

You could try casting "shadow arcs" to cover larger areas at once. While the actual details are a bit involved, Eric Lippert has a very in-depth explanation (with live Silverlight demo) at http://blogs.msdn.com/b/ericlippert/archive/2011/12/12/shadowcasting-in-c-part-one.aspx. Example step of tracing out two rays.

7

How about, rather than having a fixed viewing range, have the player's visibility area depend upon what direction the player was facing, as well as perhaps the direction the player faced in the last few turns (a player who was moving north might be able to immediately take a step south, but might take a few turns to get maximum viewing distance in that ...

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