hexagonal-tiles

Faster way to calculate hexagon grid coordinates

隐身守侯 提交于 2020-06-25 21:21:09
问题 I'm using the following procedure to calculate hexagonal polygon coordinates of a given radius for a square grid of a given extent (lower left --> upper right): def calc_polygons(startx, starty, endx, endy, radius): sl = (2 * radius) * math.tan(math.pi / 6) # calculate coordinates of the hexagon points p = sl * 0.5 b = sl * math.cos(math.radians(30)) w = b * 2 h = 2 * sl origx = startx origy = starty # offsets for moving along and up rows xoffset = b yoffset = 3 * p polygons = [] row = 1

WPF “hex grid” component

本小妞迷上赌 提交于 2020-06-11 05:50:33
问题 Jumping into the world of WPF custom controls, and was wondering what the best way to design a HexGrid control would be? Think your favorite table-top war game; or, equally likely, your favorite video game that steals the design from a proud history of table-top war games. The underlying model exposes one significant method, as a part of a Map class: Hex GetHex(int x, int y, int z)*; Hex contains all relevant data (at the moment, a Terrain enumeration that maps 1:1 to a background color;

Best Way to Store a Triangular/Hexagonal Grid in Python

纵饮孤独 提交于 2020-01-22 08:22:45
问题 I'm making a game with hexagonal tiles, and have decided upon using a triangular/hexagonal grid. I found this question which helped me generate coordinates, and slightly modified the code to store all the coordinates as keys in a dictionary with values of either "." (floor) or "X" (wall,) and included a function that prints out a string representation of the map where each non-blank character represents a hexagonal tile. This is the new code: deltas = [[1,0,-1],[0,1,-1],[-1,1,0],[-1,0,1],[0,

Perspective Coords for 2D Hex Grid

回眸只為那壹抹淺笑 提交于 2020-01-01 19:38:09
问题 Here's a stumper... Porting some old code, I have this 2D hex grid being rendered in 2.5D: The y-scale & position of the tiles is calculated for perspective, but I'd like to scale & position them for perspective horizontally as well (the toons at the top of the board look squished). Here's the current code: const SCALE_X = PixiStages.game._width * 0.0012; const SCALE_Y = PixiStages.game._height * 0.0018; this.scale.x = SCALE_X; this.scale.y = SCALE_Y * ( 0.5 + 0.5 * gamePiece.y / Game.TILE

Creating grid of hexagons

我只是一个虾纸丫 提交于 2020-01-01 04:19:10
问题 I have to do a "grid" like this: Harmonic table I'm trying to create a ListView with ItemsSource="List<Note>" where every odd note in the list is moved on the bottom... Is the ListView the right control? How can I draw an exact hexagon with faces that is near next object? EDIT: hexagon drawing is solved... this is the xaml: <Path d:LayoutOverrides="None" d:LastTangent="0,0" Stroke="Blue" Fill="Red" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Margin="0" Width="100" Height="100" x

Flat topped hexes hexagonal grid coordinates To Pixel Coordinates

怎甘沉沦 提交于 2019-12-23 03:13:03
问题 I am using flat topped hexagonal grid (following the manual listed here http://www.redblobgames.com/grids/hexagons/). I need to convert my cube coordinates into pixel coordinates. I have read Hexagonal Grid Coordinates To Pixel Coordinates but the solution listed there requires some modifications to work with flat topped grid. The logic must be similar to the one described in the question linked above but I can't work it out. Definitely in case of flat top hexes x-coordinate may be used as x

Drawing a hex grid in Flash?

瘦欲@ 提交于 2019-12-21 17:27:49
问题 What's the easiest way to draw a hex grid algorithmically? How should I present them in data? For example, in a square grid, I could just save x-y coordinates.. 回答1: So hexagon is a neat library for AS3 games, it has some hexagon classes that might be handy in your research. This article has some very nice details about hexagon tiles in Flash. 回答2: There are several ways to manage hex map coordinates and most of them unintuitively insist on mapping them to x-y coordinates which is only

Binning data into a hexagonal grid in Google Maps

China☆狼群 提交于 2019-12-21 02:53:20
问题 I'm trying to display geospatial data in a hexagonal grid on a Google Map. In order to do so, given a hexagon tile grid size X I need to be able to convert ( {lat, lng} ) coordinates into the ( {lat, lng} ) centers of the hexagon grid tiles that contain them. In the end, I would like to be able to display data on a Google Map like this: Does anybody have any insight into how this is done? I've tried porting this Python hexagon binning script, binner.py to Javascript but it doesn't seem to be

Finding adjacent neighbors on a hexagonal grid

强颜欢笑 提交于 2019-12-20 23:04:33
问题 EDIT: Wrapped the example map in a code block so the formatting is correct. Ok, I'm trying to write an extremely simple A* algorithm over a hexagonal grid. I understand, and can do the A* portion. In fact, my A* works for square grids. What I can't wrap my brain around is finding neighbors with hexagons. Here's the layout for the heagonal grid 0101 0301 0201 0401 0102 0302 0202 0402 etc, etc So, what I need help with is writing a Hexagon class that, given it's hex coordinates, can generate a