🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: rec.games.programmer
Article #1400

Re: Tile systems that work?

#1400
From: neil.a.kirby
Date: Fri, 16 Oct 1992 21:11
72 lines
3487 bytes
In article <Bw7tIy.MKL@rice.edu> amitp@owlnet.rice.edu writes:

[deletions]

>As a user, I think hex-based games look prettier.  :)
>
>I tried writing a hex-based game to see how the math worked out, and
>here is my coordinate system:
>
> /---\     /---\     /---\     /---\     /---\     /---\     /---\   
>< 0,0 >---< 2,0 >---<     >---<     >---<  A  >---<     >---<     >
> >---< 1,1 >---< 3,1 >---<     >---<  A  >---<     >---<     >---<
>< 0,2 >---< 2,2 >---<     >---<  A  >---<     >---<     >---<     >
> >---< 1,3 >---< 3,3 >---<  A  >---<     >---<     >---<     >---<
>< 0,4 >---< 2,4 >---<  A  >---<     >---<     >---<     >---<     >
> >---< 1,5 >---< 3,5 >---<     >---<     >---<     >---<     >---<
>< 0,6 >---< 2,6 >---<     >---<     >---<     >---<     >---<     >
> >---< 1,7 >---< 3,7 >---<     >---<     >---<     >---<     >---<
>< 0,8 >---< 2,8 >---<  B  >---<     >---<     >---<     >---<     >
> >---< 1,9 >---<     >---<  B  >---<     >---<     >---<     >---<
>< 0,10>---< 2,10>---<     >---<  B  >---<     >---<     >---<     >
> \---/     \---/     \---/     \---/     \---/     \---/     \---/
>
>The reason I picked this over several other methods was that it's easy
>to store, because it's just a rectangular array.  (x,y div 2)
>
>Vertical columns have the same x coordinate.
>The "A" diagonal has the same x+y.
>The "B" diagonal has the same y-x.

I've been using this for a few years now, and I call the numbering system
"rational" as opposed to "hex".  It makes lots of things much easier to do
- NOTE I USE *NO* FLOATING POINT.

>
>Distances are a bit tricky, because x isn't spaced the same as y:
>    
>   d  = sqrt( ((y2-y1) / 2) ^ 2 + 
>              ((x2-x1) / sqrt(3)) ^ 2 )
>

Can do better if your range is "map range" and not "real range."  Map range
is count the minimum number of hexes traveled.

If the difference in the column numbers is greater than the row difference,
the column difference is your range.  Else take a fraction (half or third,
I don't have my code handy) or the row difference that is greater than the
column difference and add it to the column difference.

Range is cheap.  Facings/relative bearings take work.

>(Look at the equilateral triangle {(0,0),(1,1),(0,2)} to see where
> I got that)
>
>but they're not that bad once with this coordinate system.  The
>shortest path algorithm (for moving a piece from one location to
>another) is what I'm working on --- I've started with the standard
>textbook algorithm (graph traversal), but the nodes are so regular
>that I thought I might be able to find something better.

SHould be, I worked out a hex LOS routine that computes what hex is the nth
hex from hex a to hex b for anyn such that 0 <= n <= range.
>
>I didn't get very far on my game because school started, but maybe
>I'll get back to hexes someday...
>
>
>		Amit

Good luck.

Neil Kirby
Technical Details
Message-ID: <1992Oct16.211150.7096@cbnews.cb.att.com>
Path: arc1-ca.pugleaf.net!sparky!uunet!know!mips2!cass.ma02.bull.com!think.com!ames!sun-barr!cs.utexas.edu!zaphod.mps.ohio-state.edu!pacific.mps.ohio-state.edu!linac!att!cbnews!nak
References: <71405@hydra.gatech.EDU> <1992Oct15.215213.28751@mnemosyne.cs.du.edu> <Bw7tIy.MKL@rice.edu>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!know!mips2!cass.ma02.bull.com!think.com!ames!sun-barr!cs.utexas.edu!zaphod.mps.ohio-state.edu!pacific.mps.ohio-state.edu!linac!att!cbnews!nak
From: nak@cbnews.cb.att.com (neil.a.kirby)
Newsgroups: rec.games.programmer
Subject: Re: Tile systems that work?
Keywords: graphics, tiles, easy, good
Message-ID: <1992Oct16.211150.7096@cbnews.cb.att.com>
Date: 16 Oct 92 21:11:50 GMT
References: <71405@hydra.gatech.EDU> <1992Oct15.215213.28751@mnemosyne.cs.du.edu> <Bw7tIy.MKL@rice.edu>
Organization: AT&T
Lines: 72