Tile Map Slowdown Problem
Blitz3D Forums/Blitz3D Beginners Area/Tile Map Slowdown Problem
| ||
Okay, so here's the problem I'm trying to create a grid map. Which isnt such a hard task whatsoever. the problem... the more the tiles the slower the system responds. if I try to go above 20 tiles x or y then the system delays before startup and then it delays a minute or so after the app ends. This has become a nasty pain considering I'd like to make a grid tile map larger than 20 x 20. I think the problem exists within either my create_map() function or draw_map() function. here's the code for inspection: Create_map() draw_map() the "create_map()" function is applied before the while/wend loop the "draw_map()" function is applied within the while/wend loop if anyone would like to see the code, I'll gladly post it up. Help would be grand :) |
| ||
I would separate your tileset(animimage) from your tiles.. your reloading the animimage separately for each tile. Instead, load the animimage once and then just store the reference to the tileset and the frame number in the tile itself.. Also, your going through every tile when you are displaying your map... you need to only draw the tiles that are going to appear on the screen. |
| ||
alright... so how would I do all this by code? :P |
| ||
would grabimage be better than loadanimimage when it comes to separating tiles? |
| ||
global Image=LoadAnimImage("data/world_gfx/wld_1.png",16,16,0,16) global DrawWindowWidth=600 global DrawWindowHeight=300 dim Map.tile(150,10) Function create_map() For y=0 To 9 For x=0 To 149 Map(x,y)=New tile Map(x,y)\frame=rand(0,15) Next Next End Function Function drawmap(CentreX,CentreY) width=DrawWindowWidth/16 height=DrawWindowHeight/16 startx=CentreX-Width/2 starty=CentreY-Height/2 For y=starty to starty+height for x=startx to startx+width DrawImage Image,(x-startx)*16,(y-starty)*16,Map(x,y)\frame next next End Function Lots more to it but that should get you started. |
| ||
Thanks, Skully :) studying the code now |
| ||
Use triple buffering. I've posted a notice in your other thread. |