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.

DarkBASIC Discussion / Help needed! Ned a hex grid there you can move units inside.

Author
Message
Mr_Slash
21
Years of Service
User Offline
Joined: 22nd Nov 2003
Location: Sweden
Posted: 23rd Nov 2003 10:30
Hello!

i really should need some help with some source code.
im working with an turn based strategy game, there you should be
able to move units inside a hexagone grid, but im stuck, so i would
be very glad if some one has a snippet for me how to make a hexagone
grid, and it shows me how to move units inside it!

cheers
Mr.Slash

-
Jess T
Retired Moderator
21
Years of Service
User Offline
Joined: 20th Sep 2003
Location: Over There... Kablam!
Posted: 23rd Nov 2003 12:13
What do you mean by a hexagon grid?

Do you mean that the units can only move in 6 directions (around the y axis)??


Team EOD :: Programmer/Logical Engineer/All-Round Nice Guy
Mr_Slash
21
Years of Service
User Offline
Joined: 22nd Nov 2003
Location: Sweden
Posted: 23rd Nov 2003 18:32
Yes!

Exactly! It would be nice, if i can get some help!

im stuck! so im thankfull for all help i can get!

Cheers!

Mr.Slash

-
Jess T
Retired Moderator
21
Years of Service
User Offline
Joined: 20th Sep 2003
Location: Over There... Kablam!
Posted: 24th Nov 2003 08:02
What i would do (may not be the best way) would be something like (in Psuedo Code):




The six predefined angles would be something like:




And What you'd do is get the object's Y Angle, say it was 80, and you would compare that with the other angles you already have ( ie 0, 60, 120, 180, and 240 ) which would mean that the object, since it is facing closer to 60, would then be rotated to 60 rather than 80.
To do that, you'd have something like:




Once you've rotated the unit, you then need to move that unit, so in your loop, you may have:




In that code, if you follow the loop, what it does, is it first points the unit at its destination, then, the hex grid function is called (passing in the unit number), the unit is rotated acordingly, so that it is abiding by the rules of the hexagonal rotation system (ie the function).

Then the object is moved by 5 world units.

The loop is done again, the object is pointed back at it's destination point, and the new hexagonal angle is worked out from the function, and the unit is moved 5 world units again...


That's all there is to it.


If you don't understand anything, just say, and ill explain it a bit more for you.


Hope I Helped...


Team EOD :: Programmer/Logical Engineer/All-Round Nice Guy

Login to post a reply

Server time is: 2025-05-21 20:09:16
Your offset time is: 2025-05-21 20:09:16