Hi.
I'm working on a program that creates a random world map. I create a sprite for each tile on the map, and that works fine for smaller maps but for larger maps the process of creating sprites gets exponentially slower and slower. I assumed if it took 1 ms to create 1 sprite it would take 4 ms to create 4, 16 ms to create 16 and so on, but that's not the case.
Here's some results from a test program I made.
Creating 768 (map size of 32x24) sprites takes 4 ms.
Creating 3072 (map size of 64x48) sprites takes 54 ms.
Creating 12288 (map size of 128x96) sprites takes 780 ms.
Creating 49152 (map size of 256x192) sprites takes 51193 ms.
Here's the code I used for testing. Change the tileSize variable to 2, 4, 8, 16 etc. for different map sizes.
rem
rem sprite testing
rem
rem screen setup
setVirtualResolution(1024,768)
setSyncRate(60,0)
setPrintSize(16)
setPrintColor(0,0,0)
rem change tileSize to 4, 8, 16, 32 etc...
tileSize = 8
mapSizeX = 1024 / tileSize - 1
mapSizeY = 768 / tileSize - 1
spriteCount = (mapSizeX + 1) * (mapSizeY + 1)
dim map[mapSizeX,mapSizeY] as integer
time = getMilliseconds()
rem create sprites
for x = 0 to mapSizeX
for y = 0 to mapSizeY
map[x,y] = createSprite(0)
setSpriteSize(map[x,y],tileSize,-1)
setSpritePosition(map[x,y],x*tileSize,y*tileSize)
setSpriteColorRed(map[x,y],random(0,255))
next y
next x
time = getMilliseconds() - time
rem main loop
do
printc("Sprite Creation Time (milliseconds): ")
print(time)
printc("Number Of Sprites Created: ")
print(spriteCount)
sync()
loop
I would like to create maps of a size up to 1024x768 (or even larger) but that seems impossible since creating sprites for much smaller maps (256x192) takes almost a minute. And since there's no basic 2d commands like draw dot, I don't know what other options there is.
So, does anyone have a suggestion on how I can improve the process of creating sprites or some other methods I could use? (I only need to create the sprites once then grab a image of the screen for later use, but still all those sprites must be created...

)