PDA

Click to See Complete Forum and Search --> : Hexagonal Maps


station-7.com
Dec 13th, 2000, 04:19 AM
Hi everyone,

I'm new to this forum (well, I've been lurking for a good few months now, just registered, though) and I've already got a question to throw out here. My main interest in Visual Basic is in game programming (I learned programming in C and C++, yet for some reason I've recently become obsessed with proving that Visual Basic can make top quality games) and I was hoping to expand my knowledge base a bit in an area where it is completely lacking - doing anything with hexagons.

I don't know how many of you have played computer games such as Heroes of Might and Magic (or any tabletop wargame that uses a hex board), but what I'm looking to do is make a simple 'game board' consisting of a number of hexes. Unfortunetly, I lack any knowledge on the subject and wouldn't even know where to start. If anyone could provide a good explanation of the math behind this I would be extremely appreciative. Please no source code, though. I'm not looking to copy someone elses work or to memorize code, I'm more interested in understanding the process.

-George

kedaman
Dec 13th, 2000, 02:57 PM
Ok, first off, it's very possible to make games with vb, but you have better advantages making a good quality game in C++. But since you seem to want to proove it can be done with vb to, then you just need to be as stubborn as i am, since i've always tried to do games with VB, including such with elevated hextiles such as in settlers2.
mapping a hexagonal area is probably easiest done with a tilted view:

_____
\/\/\/
\/\/\/
\/\/\/
\/\/\/

whereas all tiles actually are triangle each even \/ and each odd /\. 6 of these forms a hexgon as you can see. The coordinates for each vertex is given by this formula:
pixelx=(x+y/2)*tilewidth
pixely=y*tileheight+heightoffset*elevation <-- this is if you need to have elevation.

To draw these you need to use either bitblt or Ddraw, Ddraw is probably the best if you want to have a good quality game, although using that you are using a lot more C++ implementations than with bitblt lol. well if you need more help just ask.

station-7.com
Dec 13th, 2000, 03:30 PM
Hmmm.... yeah, I definetly see what you're saying. Thanks a lot for the help. My first program using your idea was kind of a mess (maybe I'm just a slow learning? hehe..), but then I revised it a bit and I'm off to a much better start. I managed to pretty much work out all the bugs I had in it and it looks like I've got my first working hex map program. Thanks a lot! ...

As for game programming in VB -- yeah, I've had my fair share of hurtles to get over, but I am a pretty stubborn guy and I've kept with it (satisfying my C++ addiction by writing tutorials for my soon to be launched website :)). I'm very familiar with using DX7 in C++, but I've come to understand that both DX7 and DX8 (which I just downloaded the full sdk for) have a good deal of Visual Basic support. Guess it's time to check eight out...

...anyway, thanks again for the help.

[Edited by station-7.com on 12-14-2000 at 06:43 AM]

kedaman
Dec 14th, 2000, 02:35 AM
oh, you're familiar with using DX7 in C++, since were actually going in opposite direction, i know how to use DX7 in VB, and want to go on learning it in C++ and you on the other hand want to learn it in VB, i thought we might help each other ;) do you have ICQ or something^?