Tag Info

Hot answers tagged

16

No. √3 is an irrational number, and by definition an irrational number can not be used as a ratio between two natural numbers (integers) such as pixel counts. However, there is no rule that says you have to use ideal hexagons in your game tiles. If you approximate it closely and avoid any miscalculations that may result, which you should be able to do ...


5

As long as your movement space isn't Euclidean and things can block an entire grid space, you'll have this problem. If you want people to not "play the grid" you're probably going to have to not use a grid.


4

Just in case anyone is interested: Lets assume sqrt(3) is rational: Therefore, there must be two integral numbers a and b such that a/b = sqrt(3) We assume these numbers are coprime, if they have a common factor, we divide by it producing a coprime pair, a and b We know that (a/b)^2 = 3 and therefore a^2 = 3 * b^2. 3 * b^2 is devisible by 3 as b^2 is ...


3

(I don't have enough reputation to comment) The answer here is that the distances are wrong. A is closer than B. To convince yourself, compare A and the reflection of B w.r.t. the player, so I don't think there is an issue here. Hex grids are tricky in a lot of ways.


3

The logic is simple: your contour is the set of all the edges that separate border tiles from non-border tiles. You can code the following: for each boundary tile for each edge if edge is shared with a hex tile that is NOT in the boundary tile list mark as contour edge render all contour edges Note that if you want the contour to ...


1

I've already answered a similar question, with identical goals, over on Stack Overflow I'll repost it here for convinience: (NB - all code is written and tested in Java) This image shows the top left corner of a hexagonal grid and overlaid is a blue square grid. It is easy to find which of the squares a point is inside and this would give a rough ...


1

Compare a line between the center of the nearest hex shape within a close radius of the mouse and the mouse itself and get the angle of the line between them relative to the horizontal axis of the grid. Then you could use a function like. public Vector2 CalcHexPositionFromAngle(double angle, Vector2 point, double radius) { //assume the ...


1

The way I might approach it is to create a list of all possible hex center locations during the initialization stage before the game loop starts. Then during the game loop, if there is a mouse click within 1.5 tile radius (or whatever dist you think is approp) of a white tile, simply iterate the list and find the closest list Point to the click point. If the ...



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