Tag Info

New answers tagged

1

I'd use two rules, one for tiles and one for corners of tiles: If a floor tile is surrounded by three wall tiles and one floor tile, then that floor tile is an end of of a corridor, and should be marked with a waypoint. If a corner is surrounded by one wall tile and three floor tiles, then that corner is a place where you might want to make a turn. The ...


1

First off, I would store paths as an array of points/vectors/ whatever they call it in the framework you're using. It's a coordinate, using x and y variables. When the player builds a path, you know the x and y coordinates of that point (let's call them points). For all your path arrays, check if it contains one of the 8 adjecant points (same x, but y+1, ...


0

This is rather problem to sum numbers between n and m, which is pretty widely known: it is sum of numbers 1 to m minus sum of numbers 1 to n(n-1 infact, but it gets eliminated in the code) plus x, ofcourse. In your example, it is: index = columnCount * ( columnCount + 1 ) / 2 - ( columnCount - y ) * ( columnCount - y + 1 ) / 2 ) + x; plus, since column ...


0

You just need to modify your A* implementation to exit when there are no acceptable tiles left and save all tiles meeting the condition. Start as usual and set a MaxCost value (that is max distance unit can walk). Then iterate possible tiles to go and add ones that are passable and whose cost is less than or equal than MaxCost to a list. Algorithm ends when ...


3

I start with coordinate systems — the coordinates for grid locations are (x,y) but as Krom mentioned in a different answer, for walls there can be up to two walls for each grid location. That leads to a second coordinate system, for edges between tiles. In this article I used West and South so the edges can be (x,y,West) or (x,y,South), but you can pick two ...


1

Hopefully this C# is okay for you - my c++ is very rusty: abstract class MapFeature { public void Draw(); public bool IsWall(); } enum Direction { North, South, East, West } class Wall : MapFeature { public bool IsWall() { return true; } public Tile Front, Back; // Tiles on either side of the wall, otherwise null. #region ...


4

In each tile you can store walls it has on North and East. That way each tile needs to store only 2 more booleans (or ints, if you want to store wall type). Downside is that tiles along South and West edges cannot have walls on South and West unless you add a one more row of hidden tiles that will have them.


2

In each tile, it could store the neighbours (or connectivity) that it has access to. Perhaps as a bitmap. The walls are where the two adjacent tiles are not connected. This is very friendly with A*. The second approach is to store the connectivity of tile as a enumeration. For example, a fully open tile is 0, a tile with wall to north and rest open is 1, a ...



Top 50 recent answers are included