🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: rec.games.programmer
Article #1383

Re: Tile systems that work?

#1383
From: Amit J Patel
Date: Fri, 16 Oct 1992 13:01
61 lines
3210 bytes
In article <1992Oct15.215213.28751@mnemosyne.cs.du.edu>, vputz@nyx.cs.du.edu (Victor Putz) writes:
|> 
|> Yes!  At last someone who has agonized about this as well!  I'm doing much
|> tthe same (tile-based wargame), and finally decided on the square format
|> with a twist or two.  Each piece on a square has it's in-square position,
|> so the game acts as if it's on a much finer grid than the map of tiles. 
|> Distance becomes a little easier, since it's absolute, pythagoras-style
|> distance.
|> 

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.

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 )

(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.

I didn't get very far on my game because school started, but maybe
I'll get back to hexes someday...


		Amit



-- 
/\\ Amit J Patel, amitp@owlnet.rice.edu
\\/ I think I'm at Rice University 
Technical Details
Message-ID: <Bw7tIy.MKL@rice.edu>
Path: arc1-ca.pugleaf.net!sparky!uunet!olivea!charnel!rat!usc!sdd.hp.com!cs.utexas.edu!uwm.edu!zaphod.mps.ohio-state.edu!uakari.primate.wisc.edu!usenet.coe.montana.edu!news.u.washington.edu!uw-beaver!rice!owlnet.rice.edu!amitp
References: <71405@hydra.gatech.EDU> <1992Oct15.215213.28751@mnemosyne.cs.du.edu>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!olivea!charnel!rat!usc!sdd.hp.com!cs.utexas.edu!uwm.edu!zaphod.mps.ohio-state.edu!uakari.primate.wisc.edu!usenet.coe.montana.edu!news.u.washington.edu!uw-beaver!rice!owlnet.rice.edu!amitp
From: amitp@owlnet.rice.edu (Amit J Patel)
Newsgroups: rec.games.programmer
Subject: Re: Tile systems that work?
Keywords: graphics, tiles, easy, good
Message-ID: <Bw7tIy.MKL@rice.edu>
Date: 16 Oct 92 13:01:46 GMT
References: <71405@hydra.gatech.EDU> <1992Oct15.215213.28751@mnemosyne.cs.du.edu>
Sender: news@rice.edu (News)
Reply-To: amitp@owlnet.rice.edu
Organization: Rice University
Lines: 61