background preloader

Game Programming

Facebook Twitter

Untitled. Hexagon. Hexagonal structures[edit] Regular hexagon[edit] The regular hexagon has a number of subsymmetries that can be seen by coloring or geometric variations The area of a regular hexagon of side length t is given by An alternative formula for area is A = 1.5dt where the length d is the distance between the parallel sides (also referred to as the flat-to-flat distance), or the height of the hexagon when it sits on one side as base, or the diameter of the inscribed circle.

Hexagon

Another alternative formula for the area if only the flat-to-flat distance, d, is known, is given by The area can also be found by the formulas and , where a is the apothem and p is the perimeter. The perimeter of a regular hexagon of side length t is 6t, its maximal diameter 2t, and its minimal diameter If a regular hexagon has successive vertices A, B, C, D, E, F and if P is any point on the circumscribing circle between B and C, then PE + PF = PA + PB + PC + PD. Cyclic hexagon[edit] Hexagon inscribed in a conic section[edit] Understanding hexagonal tiles. You should already know Tile Maps: they are often used for the level design in two-dimensional games.

Understanding hexagonal tiles

The most used (and simplest) tiling system has squares. Tileball is an example of a game made with this method. Even if there are a lot of games using this tiling system, it’s easy to find its limit. All movements are restricted to four directions: up, down, left, right. Some more complex games require a more complex tiling system. That’s why I am introducing you the hexagon based tile system (hex maps from now on) Wkipedia explains us the advantage of a hex map over a square grid map is that the distance between the center of each hex cell and the center of all six adjacent hex cells remains constant.

Tile based games. While you may think rectangles are only shapes that can be used in tiles, it is not true.

Tile based games

You can use other shapes too, for example triangles. In this chapter we will look how to use hexagonal tiles. Hexagonal grid is widely used in strategic board games as it allows 3 directions of movement while keeping the distance in each direction equal. Diagonal movement in square based grid is not good because the distance in diagonal is different then distance in horisontal/vertical. A regular hexagon has six edges and looks like this: Important variables to remember here are the height and size which we will be using to place tiles correctly on the stage. Vertically each next tile is placed down by the value of tiles height. tile3. Plus every other row is moved additionally down by half of the tiles height. Tile. Horisontally each tile is placed right by the value: tileC.

We obviously need to find somehow value of size (s) to place the hexagonal tiles. S=h/cos(30)/2 x=_x/s/1.5; y=(_y-(x%2)*h/2)/h; Top.