Tag Info

Hot answers tagged

6

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


6

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


5

You are actually halfway there but you skipped one important step. The trick is to use Minkowski subtraction before your hexagon technique. Here are your rectangles A and B: Now replace rectangle A with a point, and rectangle B with a rectangle of size A+B. The Minkowski addition properties state that collision between the point and the new rectangle ...


1

I don't think using the 'hexagon' is all that helpful. Here's a sketch of a way to get exact collisions for axis-aligned rectangles: Two axis-aligned rectangles overlap if and only if their X coordinate ranges overlap and their Y coordinate ranges overlap. (This can be seen as a special case of the separating axis theorem.) That is, if you project the ...


1

I don't think there is an easy way to calculate the collision of polygons with more sides than a rectangle. I would break it down into primitive shapes like lines and squares: function objectsWillCollide(object1,object2) { var lineA, lineB, lineC, lineD; //get projected paths of objects and store them in the 'line' variables var AC = ...


1

Consider this: public sealed partial class HexCoords { static HexCoords() { MatrixUserToCanon = new IntMatrix2D(2, 1, 0,2, 0,0, 2); MatrixCanonToUser = new IntMatrix2D(2,-1, 0,2, 0,1, 2); } protected HexCoords(CoordsType coordsType, IntVector2D vector) { switch(coordsType) { default: case CoordsType.Canon: _vectorCanon ...



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