Thursday, June 8, 2017

2d - Technical differences between square and hexagon for a grid?


I'm developing a 2D city-building game and trying to decide on the type of grid. There will be vehicles, so the unit movement is important too.


I know there are visual differences for using Squares or Hexagons, what I want know is:




  • What are the issues for programming each type of grid regarding implementation and performance?

  • Is there a tradeoff or specific benefit for using one of them in a game context?



Answer



I'd consider a Square-based grid as a "base" type of tiles in any game. Such grid is simple to imagine and moves over this grid are simple to understand. It's also very simple to implement "under the hood". Those are few reasons why even the Chess game uses it :). Additionally, this grid helps you make "regular" levels, because Vertical and Horizontal are natural directions here. So if you make, let's say a SimCity clone it's very easy to have perpendicular roads.


The biggest disadvantage of Square-based grids is that they doesn't keep distances very well, because when you move by one tile in N/W/E/S directions you basically move by one tile size, but when you move in directions like NW/ES/... then you'll move by sqrt(2)*tileSize. It's not so big problem in computer games but it was a big flaw in strategy/tactical board games.


Because of this problem people tried to find some other way to divide 2D space, so the movements between tiles would be more similar to the real movement. It happens that the only possible way, better than squares is to use Hexagons.


Hexagon-based grids are much better for strategy-like games because movements are more natural, but they are much harder to implement. They have also 3 main directions, where one of them may be Horizontal OR Vertical but not both! So try to imagine a city with perpendicular roads built on a such grid...


Personally, for a game like SimCity I wouldn't think much and used Squares. In fact, I'd use squares in every game that is not a turn-based tactical game. But depending on your taste you need to choose your own. Maybe you'll want to make a one-of-its-kind, Hex-based SimCity clone :) ?


No comments:

Post a Comment

Simple past, Present perfect Past perfect

Can you tell me which form of the following sentences is the correct one please? Imagine two friends discussing the gym... I was in a good s...