# Hexagon Tile Map

This topic is 3709 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hello, I'm trying to come up with the standard size of a hexagon in my hexagon tile map. I'm having extreme difficulty for some odd reason. Do most developers use irregular hexagons? If so, can anyone provide some information? So far, I can't come up with a way to use a perfect hexagon and provide pixel perfect placement (can only get whole numbers for either height or width, not both). Any help would be appreciated. Ryan

##### Share on other sites
Isometric games with pixel perfect layouts generally use irregular hexagons, for a given value of "irregular". Let's say you have a width of 60 pixels for your hexagons, which would give you a triangular height of about 17.32 pixels. The visual difference between 17.32 and 17 pixels is very, very small.

##### Share on other sites
Is it then feasible to use a perfect hexagon, and when it comes time to apply the math, simply round the results when I go to display?

##### Share on other sites
I'm not sure what you're asking.

##### Share on other sites
// Here's my constants#define PI 3.1415926535897932384626433832795int SCREEN_WIDTH = 800;int SCREEN_HEIGHT = 600;int HEX_WIDTH = 128;int HEX_HEIGHT = 110;double HEX_SIDE = floor(HEX_HEIGHT / 2 / cos(30 * PI / 180));// Here's my render loopfor (int x = 0, col = 0; x < SCREEN_WIDTH; col++, x = col * HEX_SIDE * 1.5) {	for (int y = 0, row = 0; y < SCREEN_HEIGHT; y += HEX_HEIGHT, row++) {		Render(x, row * HEX_HEIGHT + (col % 2) * HEX_HEIGHT / 2);	}}

The code above seems to work.

Screenshot:

I just want to make this is the correct way to do this.

• 33
• 12
• 10
• 9
• 9
• ### Forum Statistics

• Total Topics
631352
• Total Posts
2999486
×

## Important Information

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!