Hey, I'm trying to generate a hex-based map by getting the information from a mysql database.

The link to the map page is at http://war3online.com/game.php?view=localmap

My mysql table is just simple x,y columns all the way down. The main problem I can't figure out is how to make it automatically generate the x.png image at the beginning of the line and end of the first line on the map which gives it the hex look to it.

Any comments or suggestions are highly appreciated, thanks in advance! 🙂

    what? I see a lot of hexagons arranged so they "fit" together. What are you trying to do. Perhaps a better reference image, like one with what you have (link above) and one with what you want (made in photoshop or paint or whatever).

      hey, sorry I wasn't clear before. basically have a mysql table with two fields, x and y. x and y represent coordinates on a map i'm trying to draw. Right now, on the page you saw, I made the map in html. It's just using tables and stuff, but now I want to make it generate the map from the information from the mysql database. Using the center hex as the midpoint, I'm trying to figure out how to generate the map area blocks around him so that it'll keep auto-generating no matter where he moves around to.

        Have you seen the GD library?

        http://www.php.net/gd

        That is the drawing extension that almost every PHP installation comes with. That's what you'd need to use to generate the hex items.

        Placement, that's a whole different story, and will take some mathematics...

          As for placement, let me make a couple of observations.

          You'll do better to think about x,y placement from the upper left corner of the figure than from the center...that's where the computer will start drawing, upper left corner.

          These figures are all equal, however. So the distance center-to-center will be exactly the same as the difference upper left to upper left.

          Next, you are thinking, it seems, at placing the figures on a diagonal. That's a good place to start, but not very helpful place to end.

          In fact what you're probably going to do is place rows with gaps and columns with gaps:

          Assume the height of the figure is 10px, width 10px

          To start your grid, you place figures at
          0,0
          0,20
          0,40
          0,60

          etc
          next row is half way down. Place figures into the gaps created by the first row

          5,10
          5,30
          5,50

          etc

          Next another row...again figures into gaps

          10,0
          10,20
          10,40
          10, 60
          etc

          Just a thought on how to proceed.

            Write a Reply...