How to create a hexagon world map in PHP from a database for a browser-based strategy

I am trying to create a hexagon world map for my PHP browser based game strategy. I created a table in my database with the following data in a row: id, type, x, y and occupied. Where type is the type of tiles that are defined in numbers. For example, 1 is grass. The card itself is 25 x 25.

I want to draw a map from the database using interactive fragments and the ability to navigate the map with arrows. I really don't know how to start from this, and any help would be appreciated.

Thanks in advance,

Fabian


I understand that I have to use Javascript with this, but I still don't know how to create arrays to load fragments and coordinates from the database and display them using javascript on the page.

+3
source share
3 answers

Assuming you're asking about a six-segment mesh, a very good idea for creating hex fragments using Javascript can be found by Ron Martin

alt text

From now on, you just need to handle the click events in order to use your PHP.

+2
source

You will definitely need javascript code for this. I would recommend using jQuery as an e framework. It has everything you need: event capturing (click, button click), DOM manipulation, etc.

0
source
0
source

Source: https://habr.com/ru/post/1779618/


All Articles