Hex Gameboard System


was8bit 2021-11-01 04:17 (Edited)

INTRODUCING, a complete Hex Gameboard system...

Designed as a virtual hexagonal gameboard, for turn-based games (although if you are clever, may have some limited ability for action games)

The "game code" section supplied is mainly for demonstration and testing purposes... you are free to remove this game code, and write your own game code :) just be sure not to mess with the top HEX INITIALIZE or HEX SUBS sections...

Map data needs to be character image#... be sure to plan your images accordingly... image#8 is an empty hex (#1-7 are reserved for cursor animation) image#9 and higher are free for use as images/map-data of things places on the hex map

Below is a brief overview of how to use the Hex System ...


Place this CALL inside your game's main DO LOOP, i use WAIT 6, you may adjust... use these x,y variables for other sub calls to perform where the cursor is at

Actual cell locations do NOT correspond with the map/cursor locations... so if you know your cell coordinates you want, use the GETPUT function to convert to map/cursor coordinates

CALL HEX_GETPUT(x,y) x=0 to 18, y=0 to 15
x,y are cell coordinates, outputs hexmap and cursor coordinates

If you already know the map/cursor coordinates, you can access the map data directly, read or write cell image#, with...


Clear or draw the map with


Below are the hex functions, and the hex data arrays that store the results of the function..

CALL HEX_PROXIMITY(x,y) input hexmap or cursor x,y
HEXDAT_PROXIMITY(i) where i=1 to 6
this returns the cell image# and its location, letting you read and or change the cell image... it checks all 6 cells that surround the x,y entered in the CALL

CALL HEX_RAYTRACE(x,y,d) where d is direction 1-6, x,y as above function
this returns the cell image# and its location, in the inputed direction, up to possibly 20 cells, letting you read and or change the cell image

For both above functions, a cell value of "-1" mean that location was out of bounds for the map array, do NOT attempt to write a value to a cell "-1"

*final note*
All Hex graphics are placed on BG 1, so leave that alone, and only use BG 0 for things like scores, etc...

Hex Board Test 7.nx | Open in app
2021-11-06 04:13
Hex Board Test 6.nx | Open in app
2021-11-05 08:05
Hex Board Test 5.nx | Open in app
2021-11-04 17:08
Hex Board Test 4.nx | Open in app
2021-11-04 07:55
Hex Board Test 3.nx | Open in app
2021-11-01 17:11
Hex Board Test 2.nx | Open in app
2021-11-01 08:15
Hex Board Test 1.nx | Open in app
2021-11-01 04:17

nousername010 2021-11-01 06:43

I can see the possibilty of a lowres Civilization

was8bit 2021-11-01 08:18

... lots of possibilities :)

I will have to be mindful of creating a system that is easily reusable for different applications....

was8bit 2021-11-01 17:18

I think i like the #3 test layout... the simpler design makes it easier to see how things line up so you can better decide WHERE to place a new piece....

was8bit 2021-11-01 17:46

Ok, on-screen controls works correctly, although abit clunky, they work..

... next is to create a database that is editable via cursor and displays properly...

nousername010 2021-11-02 03:01

Looks like it's getting better! I wish I had the brain to work with this.

Just a suggestion, all the hex games I've played so far alternate between left and right hexes when moving vertically, removing the need to press a button to go up or down. I'd try to see if this can be done, but I'm busy atm :p.

was8bit 2021-11-02 05:28 (Edited)

... yes, i have fixed the cursor movement to entirely using the arrow keys, freeing up A and B buttons for other uses... :)

I am experiencing some database bugs though... when i get them cleared i will post another update ... it should, at that point, be nearly ready for publication :)

nousername010 2021-11-02 05:29

Okay, that took less time than I thought.

I commented the changes I did in this alternate movement system I suggested.

nousername010 2021-11-02 05:30

Woops, didn't see your reply.

Anyway, yeah, I noticed subtle but unexpected behavior in my code. Nothing too major I hope.

was8bit 2021-11-02 05:36 (Edited)

Ah, your fix works too :) ... thanks so much for taking the time :)

... but in mine i removed the U/D movement, as i wanted the cursor to follow the lines of connection...

I must be getting tired brains, as i am experimenting with new stuff and am getting unexpected results.. maybe when i am more awake i will iron out things for the next update :)

was8bit 2021-11-02 05:38 (Edited)

... you will notice that i rewrote my code... it is based on making the code more inside SUBS, making it easier to be used in any game...

i am also trying to make it cursor based... this, though, needs rewritten better...

nousername010 2021-11-02 08:50

You've done quite a lot of work, get some rest. You can think better once you recover your energy :)

was8bit 2021-11-03 03:49

Thanky :) i spend alot of time between work, family, travel, etc.. as well as having trouble falling asleep...

was8bit 2021-11-04 10:16 (Edited)

I "think" i am close to being finished... i just need to go over the code again, clean it up, and organize it so it can be used as a hex tool for most games, primarily turn based games...

I will want to add some additional functions as well... PROXIMITY and RACTRACE, to let the code check a single point and (Proximity to see all surrounding cells) ... and (Raytrace to see all cells down a certain direction)

was8bit 2021-11-05 09:24

Everything is working... however i am unsatisfied on how i got it to work... so i am going to rethink my approach .... it also needs to be more user friendly as a tool for making different kinds of games...

was8bit 2021-11-07 00:16

I am currently needing to make all my functions operate on the same format... I have reworked the code using different approaches, so I need to get everything operating the same way...

After that, I will make a simple game with it :)

nousername010 2021-11-07 00:43

Looks really good! Nice to see you got most of the bugs fixed.

I do wonder what game you're going to make with it. Mind if I ask?

was8bit 2021-11-07 04:54

Thanks so much... I have a bad record of trying to make games and not finishing them... so I have been trying to do smaller tasks and focus harder and have more organized code.. I am improving :)

As far as my first game from this will be a VERY simple one, vaguely based on GO, but it won't really be GO... it will be a very VERY simplified capture game based on surrounding a single enemy spot with 3 of your spots... and it will take a twist or two from there... possible to be used for some kind of online gaming :)

THEN I would really like to make my idea of a variation of OTHELLO, with some of twists in it, for a second game... :D

... then i need to revisit existing projects, and get them up and running....

was8bit 2021-11-07 05:02

... so, you can see how my PROXIMITY function will be useful for my capture game, and how my RAYTRACE function will be needed for my othello game...

The concept for this system is that it is a simulated hex game board... so most likely to be used for turn-based board games.... however it might be able to used for an action game, a Maze game, a dungeon game, etc... with some clever planning ....

Can I think of any other functions that could be generically useful for this system ??

was8bit 2021-11-07 08:42

Weeee... i am going to be super tired tommorow, but i couldn't sleep, AND i had a clear mind to work on this... so i finished it :D

was8bit 2021-11-07 09:14

Here is a preliminary peek at my game... i will be changing the name, i think, and adding more stuff...

I Capture.nx | Open in app
2021-11-07 09:14

was8bit 2021-11-07 10:48

Well, i need to TRY to sleep, so i posted what i have added as a WIP, and will finish it later :)

nousername010 2021-11-07 13:59

From what I've seen so far from your game, I don't think I can suggest any more :)

That said, I guess a width and height var could be utilized for games that wish to have the UI on the side

was8bit 2021-11-07 14:53

Well, length can be easily calculated using RAYTRACE... as it starts out where you are at, then at the point of the first "-1" return, that's the length to the boards edge...

So if you use FOR I=1 TO 20 and you hit a "-1" return at I=7 then you know you are 7 steps away from the boards edge in that direction..

There are 6 directions, so you will have 6 different results...

Now, if an edge detector, with a simple array that already has all 6 lengths stored in it, would be useful for you, i would be very happy to add that... in fact, I think I will go ahead and add it anyway, it sounds rather cool :)

was8bit 2021-11-07 14:57

Now, if you are saying you want a different sized board, this is easily done by editing this...

BG 1
FOR Y=0 TO 15
FOR X=0 TO 36 STEP 2
CELL X\2,Y,8

Just tweak the values, so say change TO 36 until you get what you want...

The functions can already handle the situation of going beyond the board via detecting no board directly, they don't rely on the board size, so making the gsmeboard smaller won't effect them :)

was8bit 2021-11-07 15:35 (Edited)

Oh, one more thing, in HEX_CURSOR_MOVE you will also need to tweak


This may be a tricky thing to do, you will have to test your settings to be sure your cursor doesn't go off the boards smaller edges...

Log in to reply.