when using arrays they start at 0 so
32 images would be 0 to 31
try adding -1 to
tilesx
tilesy
ie
Function Drawtiles()
'DebugStop()
For Local i% = 0 Until tilesx-1
For Local j% = 0 Until tilesy-1
DrawImage (imagemap[i,j],i*twidth,j*theight)
Next
Next
DebugLog "Tiles Drawn"
End Function