I am using this code to generate the board:
function createBoard(width, height)
for w = 0 to width
for h = 0 to height
boardpiece[w,h].x = 1 * w
boardpiece[w,h].z = 1 * h
boardpiece[w,h].id = CreateObjectBox(BOARD_WIDTH, BOARD_HEIGHT, 1)
SetObjectPosition(boardpiece[w,h].id, boardpiece[w,h].x, 0, boardpiece[w,h].z)
SetObjectColor(boardpiece[w,h].id, COLOR_NORMAL_RED, COLOR_NORMAL_GREEN, COLOR_NORMAL_BLUE, 100)
next h
next w
endfunction
The issue I am having is the board's y origin is backwards. That is 0 is at the bottom and 7 is at the top. I tried changing it to:
function createBoard(width, height)
for w = 0 to width
for h = height to 0 step -1
boardpiece[w,h].x = 1 * w
boardpiece[w,h].z = 1 * h
boardpiece[w,h].id = CreateObjectBox(BOARD_WIDTH, BOARD_HEIGHT, 1)
SetObjectPosition(boardpiece[w,h].id, boardpiece[w,h].x, 0, boardpiece[w,h].z)
SetObjectColor(boardpiece[w,h].id, COLOR_NORMAL_RED, COLOR_NORMAL_GREEN, COLOR_NORMAL_BLUE, 100)
next h
next w
endfunction
However it made no difference and the baord was still backwards. I also checked my highlight code but, all it does is take a x and z coordinate and uses that information to get the ID from the object type.
function highlightCursor(x as integer, z as integer, r, g, b, a)
objectid as integer
objectid = BoardPiece[x, z].id
SetObjectColor(objectid, r, g, b, a)
endfunction
The only other thing I can try is reversing the loop so its height outer, width inner , but it's late, and I am tired. I have attached the source code for reference.
UPDATE
I got objects to spawn on the cursor by changing this line from:
SetObjectPosition(playerdefense[playerdefensecounter].id, playerdefense[playerdefensecounter].x, 2, 5 - cellz)
to:
SetObjectPosition(playerdefense[playerdefensecounter].id, playerdefense[playerdefensecounter].x, 2, cellz)
but the issue still persists and the board's z coordinate is still reversed.