Trouble with Hex Map

Tryin to draw my temp hex tiles, but i am having problems getting them to 'stick' horizontially, ive read tuts. but my problem is that i dont know how to find the length of each side on the hexagon, i need that for the other problems to work, but ive gone this far with just dividing the rectangular hexagon image.

code:

// even row

if (i%2==0){

hexGraphic[i][j].draw(g,

(int)xPos+i*HEX_SIZE,

(int)yPos+j*HEX_SIZE);

}

// odd row

else{

hexGraphic[i][j].draw(g,

(int)xPos+i*HEX_SIZE,

(int)yPos+j*HEX_SIZE+HEX_SIZE/2);

}

picture:

http://img295.imageshack.us/img295/8981/hexhelpni9.png

[1046 byte] By [DarkMortara] at [2007-11-26 16:29:34]
# 1

Hi Mortar,

You are obviously obtaining your X positions by multiplying the column numbers with the width of the OUTER BOUNDING BOX of your hexes. (This includes the width of the top or bottom line of a hex, plus the width of both protruding points.) If you were to align them vertically (not adding half a HEX_SIZE to the Y position of the odd rows) then the points of your hexes would just touch.

However, in a hexgrid, the outer bounding boxes need to overlap. What you need to do is to remove the width of one protruding point from your calculation.

So instead of calculating your horizontal hex size as something like:

size = topLineWidth + pointProtrusion * 2;

you should calculate it as:

size = topLineWidth + pointProtrusion;

GJosefa at 2007-7-8 22:53:58 > top of Java-index,Other Topics,Java Game Development...
# 2
Sorry for the off-topic questions, but how did you get those Translucent labels in your program?
Bobert.a at 2007-7-8 22:53:58 > top of Java-index,Other Topics,Java Game Development...
# 3
Berbert see: http://www.cokeandcode.com/spaceinvaderstutorialAnd its funny u registered one day before me, and the day you registered was on my birthday :P
DarkMortara at 2007-7-8 22:53:58 > top of Java-index,Other Topics,Java Game Development...
# 4

I was looking at some other tutorials and replaced the code with this: i use 0.75 to represent the overlapping part:

// even row

if (i%2==0) {

hexGraphic[i][j].draw(g,

(int)xPos+i*(int)(HEX_SIZE*0.75),

(int)yPos+j*HEX_SIZE);

}

// odd row

else {

hexGraphic[i][j].draw(g,

(int)xPos+i*(int)(HEX_SIZE*0.75),

(int)yPos+j*HEX_SIZE+HEX_SIZE/2);

}

is there anything wrong with this? it seems to work fine, i just hope it doesnt mess up other calculations for placing objects on certain hex coords.

DarkMortara at 2007-7-8 22:53:58 > top of Java-index,Other Topics,Java Game Development...
# 5
You have to bear in mind that you're the only person on this forum who knows the orientation of your hex image.
YAT_Archivista at 2007-7-8 22:53:58 > top of Java-index,Other Topics,Java Game Development...
# 6
Well my screenshot says so, its vertical and they are 80x80px in size.as in... __/\\__/Message was edited by: DarkMortar
DarkMortara at 2007-7-8 22:53:58 > top of Java-index,Other Topics,Java Game Development...
# 7
> Well my screenshot says so, its vertical and they are> 80x80px in size.You need to find some way of calculating the top/bottom lengths.
CaptainMorgan08a at 2007-7-8 22:53:58 > top of Java-index,Other Topics,Java Game Development...
# 8
> Berbert see:> http://www.cokeandcode.com/spaceinvaderstutorialSorry to be a pest, but I did not find anything on that site. Thanks for the link, though. :)
Bobert.a at 2007-7-8 22:53:58 > top of Java-index,Other Topics,Java Game Development...
# 9
My apologies. I scrolled back up, but missed the link.0.75 is correct (for your hexes and for regular ones).
YAT_Archivista at 2007-7-8 22:53:58 > top of Java-index,Other Topics,Java Game Development...
# 10

my hex map has all the bugs fixed, and it works great, i fixed everything including visibility and everything sticks now :)

Bobert:

If you look at the code in that space invaders program, it will tell u how to use images, those monsters actually have transparency, so you look at the SpriteStore class, if u need more help on how to use it u can ask, but PLEASE read through that tutorial and try to figure out as much as you can, i will try to help.

only worry about tutorial 101 and 102, forget the rest unless u want to use LWGL.

Message was edited by:

DarkMortar

DarkMortara at 2007-7-8 22:53:58 > top of Java-index,Other Topics,Java Game Development...
# 11
Ok, I found it. I had read the tutorial, but not the code. :)
Bobert.a at 2007-7-8 22:53:58 > top of Java-index,Other Topics,Java Game Development...