View Single Post
  #15  
Old May 31st, 2001, 07:08 PM
capnq's Avatar

capnq capnq is offline
General
 
Join Date: Feb 2001
Location: Pittsburgh, PA, USA
Posts: 3,070
Thanks: 13
Thanked 9 Times in 8 Posts
capnq is on a distinguished road
Default Re: Straight vs. Diagonal

The biggest problem in coding a hexgrid that I remember was defining a coordinate system and calculating whether two hexes are adjacent. On a square grid, that's trivial: you know that square (x,y) touches square (x+1,y). On a hex grid, hex (x+1, y) still touches hex (x,y), but so does either hex (x+1,y+1) or hex (x+1,y-1), depending on whether x is odd or even. Calculating the range between two hexes is even worse.

We did this for a college programming project course, and I remember that our group and one of the other Groups came up with totally different systems to resolve this.

------------------
Cap'n Q

The most merciful thing in the world, I think, is the inability of the
human mind to correlate all of its contents. We live on a placid
island of ignorance in the midst of black seas of infinity, and it was
not meant that we should go far. -- HP Lovecraft, "The Call of Cthulhu"
__________________
Cap'n Q

"Good morning, Pooh Bear," said Eeyore gloomily. "If it is a good morning," he said. "Which I doubt," said he.
Reply With Quote