Yes, I realize this code is missing a lot of things to be remotely functional or perform reasonably. I've removed anything that didn't seem relevant to the problem.
So in the draw_map() function, it's giving an "Image does not exist" error. I added some extra code to put the array value in a variable first so I could see what the value was in debug mode and it appears to be an image pointer. Also, there are a few global values for the 3 handles of the images created that went into the array, so you can see that the image handle value being pulled from the array is one of the value handles.
I can't figure out why, even though the value is a valid image handle, the DrawImage function is throwing an error saying that it's not...
Global testvalue0
Global testvalue1
Global testvalue2
Const screen_width = 1152
Const screen_height = 864
Const screen_depth = 32
Const map_width = 512
Const map_height = 512
Const map_layers = 1
Const num_tiles = 255
Dim tiles(num_tiles)
Dim map(map_width,map_height,map_layers)
init_tiles()
init_map()
Graphics(1152,864,32,0)
SetBuffer(BackBuffer())
While(Not KeyHit(1))
ClsColor(58,110,165)
Cls
draw_map()
Flip(False)
Wend
End
Function init_tiles()
tiles(0) = CreateImage(32,32)
testvalue0 = tiles(0)
tiles(1) = CreateImage(32,32)
testvalue1 = tiles(1)
tiles(2) = CreateImage(32,32)
testvalue2 = tiles(2)
End Function
Function init_map()
For x = 0 To screenwidth-1
For y = 0 To screenheight-1
map(x,y,0) = Int(Rnd(0,2))
Next
Next
End Function
Function draw_map()
For x = 0 To map_width-1
For y = 0 To map_width-1
tile_image = tiles(map(x,y,0))
DrawImage(tile_image,x*32,y*32)
Next
Next
End Function
|