haha, whoops
Well it least it can be noted that initializing an array to 0 slots can crash it. Thanks
Edit: yup! works right now!
//swissolo
gHxWidth = 5 : gHxHeight = 5 `*`
type gHx_UT
data1 as integer `*`
data2 as integer `*`
endtype
//
gosub gHx_init
for x = 1 to gHxWidth
for y = 1 to gHxHeight
gHx[x, y].data1 = x
gHx[x, y].data2 = y
next y
next x
//*********************//
do
for y = 1 to gHxHeight
for x = 1 to gHxWidth
printc("|"+str(x)+","+str(y)+"|")
next x
print("")
for z = 1 to y
printc(" ")
next z
next y
print("")
print("2,2 adj 1,2?: "+str(gHx_Adjacent(2,2,1,2)))
print("2,2 adj 3,2?: "+str(gHx_Adjacent(2,2,3,2)))
print("2,2 adj 2,1?: "+str(gHx_Adjacent(2,2,2,1)))
print("2,2 adj 2,3?: "+str(gHx_Adjacent(2,2,2,3)))
print("2,2 adj 1,3?: "+str(gHx_Adjacent(2,2,1,3)))
print("2,2 adj 3,1?: "+str(gHx_Adjacent(2,2,3,1)))
print("2,2 adj 3,3?: "+str(gHx_Adjacent(2,2,3,3)))
print("2,2 adj 1,1?: "+str(gHx_Adjacent(2,2,1,1)))
sync()
loop
//*********************//
gHx_init:
dim gHx[gHxWidth, gHxHeight] as gHx_UT
gHx[1,0].data1 = gHxWidth `*`
gHx[0,1].data1 = gHxHeight `*`
return
function gHx_Adjacent(x1, y1, x2, y2)
`outVal = 0
//down left, down
if x1-x2 = -1 and (y1 = y2 or y1-y2 = 1) then outVal = 1
//up left, down right
if x1-x2 = 0 and (y1-y2 = 1 or y1-y2 = -1) then outVal = 1
//up right, up
if x1-x2 = 1 and (y1 = y2 or y1-y2 = -1) then outVal = 1
endfunction outVal
swis
Joined: Tue Dec 16th 2008