Advertisement

Hexagonal Maps - Problem with Tanstaafl Tutorial

Started by September 13, 2000 01:46 PM
5 comments, last by perfect 24 years, 3 months ago
I have just started to make my game (Called: Mage) and want to do it with hexagonal maps. A couple of years ago I almost finished the map-engine (square tiles) but didn''t complete it. I know many of the guys here at this forum says that there is a good tutorial from Tanstaafl at: http://www.gamedev.net/reference/articles/article747.asp I have implemented the code from the tutorial in Visual Basic 6.0 but can''t get the code to work. I have implemented the MouseMaps (GREAT IDEA by the way ;o)) ect. and have drawn the hexagonal map on the screen. But when I''m mouse-clicking on the map I have problems when transforming Point(x,y) into Map(TileX,TileY)! The problem is that the tutorial (step 1) dosen''t seem to take into account that every other row is shifted by 20 pixels! Any solutions to the problem is WELCOME! Regards Perfect
Just divide your mouses y position by half the
hexagon height and if the result is odd then add
1 to the resultant hexagons x value.
I haven't read the article but this should give you
an idea of how to work out your problem.


P.S. Use C++. Its a language for real men!


Edited by - Davaris on September 14, 2000 6:25:05 AM
"I am a pitbull on the pantleg of opportunity."George W. Bush
Advertisement
Look here :

http://fp.premier1.net/butler/mark/hexpart/hexpart.html

http://www-cs-students.stanford.edu/~amitp/Articles/GridToHex.html

Merrick

-------------------------------------------------
"Children come to us in a state of purity and perfection from the great undifferentiated absolute and then, like everything else on this planet, we fuck them up."

Edited by - morfe on September 14, 2000 6:54:45 AM
"NPCs will be inherited from the basic Entity class. They will be fully independent, and carry out their own lives oblivious to the world around them ... that is, until you set them on fire ..." -- Merrick
You are using the correct mousemap? it should be approx double the height of your hexes. I''ve implemented TANS''s code before and it''s always worked first time for me, even in VB!

Could you post the mousemap image here for someone to check, as you may have it wrong, not saying you have but about 90% of the errors I''ve seen before is from people that think it''s right but they do not see the error until someone else looks at it then they work out the problem.

Your mousemap should be something like:

+--------+|   /\   ||  /  \  || /    \ ||/      \|||      ||||      ||||      ||||      ||||      |||\      /|| \    / ||  \  /  ||   \/   ||   |    ||   |    ||   |    ||   |    ||   |    |+--------+if it''s not like that then you probably have it wrong... but then again you may not, but a second pair of eyes is better than people giving you suggestions without any knowledge of what your mousemap looks like.    
When I find my code in tons of trouble,Friends and colleages come to me,Speaking words of wisdom:"Write in C."My Web Site
Davaris,
If you look at the tutorial you''ll see that it is not as simple as that. The way that the hexagonal tiles are drawn overlapping occurs in the y-axis which makes matters more complex! But thanks for trying ;o)

Morfe,
I''ve checked out the two links but find them more complex than Tanstaafl''s tutorial. I mean - I can understand every detail in Tanstaafl''s tutorial but I just can''t seem to get it to work!

--------------
Regards
Perfect

Hi Steven,
Er... my mousemap is the same size as the hexagonal tile. I will try and make it as you have drawn it. I noticed that it had this strange form in the tutorial but I thought it was an error because of the way that the mousemap for the isometric tile looked ;o)

By the way what is the height of the mouseMap? My tile is 40x40 pixels!

Many Thanks
Perfect
Advertisement
Hi Steven,
Just implemented the mousemap as 40x60 pixels and guess what?! IT WORKED! Whoah...
Great work - thanks...

This topic is closed to new replies.

Advertisement