Tag Info

Hot answers tagged

64

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:


64

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


49

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.


35

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


24

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


17

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


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


17

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


15

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


15

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

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


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


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


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


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


6

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


6

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


6

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.


6

You allocate Grid like this: Grid = new std::vector<int>[gridx, gridy]; C++ is not C#, this does not quite what you expect. gridx, gridy is evaluated (thanks to the comma operator) to just gridy, so you are allocating an array of gridy std::vector<int>s. The same thing happens when you try to access Grid[x,y], you are actually accessing ...


6

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


5

I think your drawing is a little misleading because you choose to draw strokes from the point on the circle tangent to your moving direction. I can see that the collisions to your grid edges happends when the TOP and LEFT points of your circle touch an edge. Let C be your center and r the radius so P' = C + (r,0) and P" = C + (0,r). If D is your direction ...


5

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


5

The parallelogram coordinates you're using are easier to work with, but they do have the drawback of being weird for rectangular maps. One approach is to store it with the offset coordinates but actually use parallelogram coordinates in your game logic. Observation: in each row of the map, the grid data is contiguous. All the wasted space is on the left ...


5

It won't look good to you unless you tessellate the mesh more finely (use more triangles, use a bigger grid, and have the elevation changes go much slower) Your normals are off a bit. To find smoothed normals at a vertex, you have to take several cross products at each vertex, sum the normals you find, then normalize that normal. For example, Here you ...



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