MEMORY ACCESS ERROR

Blitz3D Forums/Blitz3D Programming/MEMORY ACCESS ERROR

OK, my code is simply! I read in a map with different Y-Values. Then I put them together to a mesh, like this:


;-------------------------------------
;Dateieinlesen
mapstream=ReadFile("map1.dat")
;Heightmap einlesen
Dim Map(255,255)
For PYR = 255 To 0 Step -1
For PXR = 0 To 255
Map(PXR,PYR) = ReadByte(mapstream)
Next
Next
;------------------------------------


;Meshcreation
For y = 0 To 120 ;maximal 126!!!
For x = 0 To 120 ;maximal 126!!!
Y1 = map(x,y)
Y2 = map(x,y+1)
Y3 = map(x+1,y+1)
Y4 = map(x+1,y)
UNLI = AddVertex( surf,x, Y1,y , 0,1)
OBLI = AddVertex( surf,x, Y2,y+1 , 0,0)
OBRE = AddVertex( surf,x+1, Y3,y+1 , 1,0)
UNRE = AddVertex( surf,x+1, Y4, y , 1,1)
AddTriangle surf, UNLI, OBLI, OBRE
AddTriangle surf, UNLI, OBRE, UNRE
Next
Next
UpdateNormals mesh