Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / Algorithm for Hexagonal coordinates on grid, using loops /arrays /types

Author
Message
HexM
16
Years of Service
User Offline
Joined: 29th Jul 2008
Location:
Posted: 30th Jul 2008 04:52

Been able to display a grid over a map at 800 X 600 resolution, however something must be wrong because when i switch to 1024 X 768 i get a bunch of extra boxes underneath my map. So i tried to go a different route.


This time i got types and arrays. Now i understand that xpos and ypos are the top corner of the bitmap im using. If you plug i into the equations it is way off the way i have it.

My title size is 80 X 80, so I know, or should i say I "think" based on my calculations every other title would be shifted down 60 and over 40. Could anyone help me reason this through, I've tried many things over the past few days. If someone could point me in the right direction i would really appreciate it, Thank you!
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 30th Jul 2008 08:34
Easier way to set it up is use a nested FOR loop, makes it a littler easier to work with. Every other row is offset by 75%, not 50% as your (i mod 2)*40 suggests.



See if that lines up any better for ya. Also, I dont think a hexagon would fit perfectly within a square image, 80x80. At least not what I've found on google images, none of the hexagons were a square image.


HexM
16
Years of Service
User Offline
Joined: 29th Jul 2008
Location:
Posted: 30th Jul 2008 09:50
Thank you very much! The nested for-loop was the correct way to go.


Thats the code that made it work... its perfect! well almost. you are right i can see a slight imperfection in the bitmap that i created, i just picked 80 X 80 out of the blue. now im going to go back and create a new hexagon, and my turn based game will be one step closer. Thank you!
HexM
16
Years of Service
User Offline
Joined: 29th Jul 2008
Location:
Posted: 31st Jul 2008 23:45
For some reason i think im going to have to start my whole project over. Maybe there is something wrong with my approach. What i want to do is be able to scroll a hexagonal map. But keep the data stored so that i know exactly which hexes are being displayed (so later i can manipulate that data by clicking).

Here are the 2 different programs, neither one getting the desired effect.


and


80 X 80 bitmaps once again, that will eventually be changed to make better hexagons.
But you can see the different approaches. Im sure everyone can see what im trying to do here. Please help! thanks
HexM
16
Years of Service
User Offline
Joined: 29th Jul 2008
Location:
Posted: 5th Aug 2008 08:00
Scrolling is fixed.


Anyone have any ideas on how to make this scroll smoothly?
HexM
16
Years of Service
User Offline
Joined: 29th Jul 2008
Location:
Posted: 5th Aug 2008 20:04


This seems to scroll smoothly in the X direction. In the Y direction it will distort the map because of hex grid layout. hmm.. anyone?

Login to post a reply

Server time is: 2024-09-27 18:20:48
Your offset time is: 2024-09-27 18:20:48