![]() |
hexagonal map handling...need help
Hello, new at Vb, as i im, i have been thinking of an hexagonal worldwar 2 game, (turnbased) but i havent found any good tutorials how to make an working engine, and how i actually make it, as in strategic command, im trying to clone this game, but i need to know the basic stuff first.
can some one please email me sources or tutorials or ideas, where i should start to learn how to make an hexagonal game ? i want to now how to draw hexagonals over an map, how to move units inside the hexagonals, etc if you have some expireice please share them with me. Thanks |
1 Attachment(s)
You can make hexagon grids with image boxes (at the simplest leve, although it'll be ugly) or by BitBlt ing a picture of a hexagon.
Of course, there are many ways to make a hexagon grid, but all of them (usually) will involve their rectangles to be overlapped. The second box will lie along 1/3 of the width of the first box, and 1/2 the height of the first box. :) Something like the picture below. |
Maybe this thread might help:
http://www.xtremevbtalk.com/show...ight=hexagonal |
Wow really impressing!
Wow it was really impressing!
But i wonder how, do i make the flags move around in the hex based map ? i see of the example how to draw hex grid, but i dont understand how to make the flags move around in the hex system ? can anyone please help me with an example code of how to make a hex grid there i can move pictures inside the hex grid ? Thanks for helping me out! Its very nice to know that there are people who cares! //your friend Slash03 |
Well, suppose you want to draw something at row R and column C. You can convert these to pixel coordinates like this:
If Row AND 1 then X = 0 ELSE X = HEXWIDTH/2 X = X + C * HEXWIDTH Y = HEXHEIGHT * R * 0.75 Now that you have (X,Y), you can draw your object there. To move stuff, you would typically erase the map, then redraw everything again. You can control flicker by setting AutoRedraw to TRUE. This means you need some kind of array in memory to keep track of what should be drawn where. |
Thanks
Thanks for helping me!
But i dont really understand how to do this, well i can make the hexgrid and i know to handle arrays but i dont understand, how to move images inside the hexgrid, i would really be happy if you got any tutorial or source code some i can study. Thanks for helping me out. Ive learned a lot from you nice people! //Slash03 |
I would suggest you check out my tile mapping example in the Code Library. Its for square tiles instead of hexagonal, but the concept is the same.
As I said, you will probably store the state of all objects on the map in an array. When you move an object, you move it in the array. You then clear the screen and redraw it based on what you have in the array. If you only have a few objects, you could substitute simple X,Y variables for the array. As for the arrays, there are 2 ways to go about it. 1) Have a 2D array that matches the map. Each element contains info on the object(s) in that hex. 2) Have a 1D array of User Defined Types. Each UDT contains info about an object including it's position on the map. |
The source gone
Hello Billsoo!
The source of the tile mapping example was gone, can you please email me the source code ? Thanks! //Your Friend Slash03 |
No, I don't have the source anymore...
But the code is in the thread...just look at the last post: http://www.xtremevbtalk.com/show...5&page=2&pp=40 |
Thanks!
Thanks!
Ive looked on it, but i think, i need to find an example of an painted picture, and there it draws a hexgrid over the picture and then how i can move units with the mouse, inside the hexgrid it must be some examples out there.... i now how you make the hexgrid, put how do i populate it with an image that i can move in any direction ? thats the source i need! Thanks! Youre a great friend, ive learned a lot from you already. //Slash |
I already suggested simply redrawing the map...but I'm sensing that you want something else. Maybe something like drag and drop?
If so, I would suggest using an image control. When you click on the map, if there is a unit there, the program will move the image there. It will then copy the unit picture into the picturebox and erase the image on the map. When you move the mouse with the button down, you simply move the image box along with it. When you stop, you copy the picture in the image box to the map, update your arrays, and make the image box invisible. |
Thanks
Yes! exactly what i need, can you give me source code how that can
be accomplished ? heres my code right now.. il send you my progg to you, and maybe if you want you can have a look on it and maybe modify it, so i can move units inside the hex map! Thanks! Youre the man! Slash03 |
1 Attachment(s)
Ooppps sorry heres the code...
|
| All times are GMT -6. The time now is 10:11 PM. |
Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
All site content is protected by the Digital Millenium Act of 1998. Copyright©2001-2007 iNET Interactive and Extreme Visual Basic Forum. All rights reserved.
You may not copy or reproduce any portion of this site without written consent.