Niften
Member
Hi everybody,
I have a draw event that draws my sandbox world. It is the draw event of the chunks and it draws all blocks in its grid. How can I improve its performance with surfaces?
I've asked about optimizing the drawing and many people have pointed me toward surfaces. What can I do to improve it?
I have a draw event that draws my sandbox world. It is the draw event of the chunks and it draws all blocks in its grid. How can I improve its performance with surfaces?
I've asked about optimizing the drawing and many people have pointed me toward surfaces. What can I do to improve it?
Code:
for(var xx=0; xx<CHUNK_SIZE; xx++) {
for(var yy=0; yy<CHUNK_SIZE; yy++) {
// Draw background blocks
if data2[# xx,yy] > 0 {
var sub = 0;
draw_sprite_ext(obj_item_control.block_sprite[data2[# xx,yy]],sub,x+xx*BLOCK_SIZE,y+yy*BLOCK_SIZE,1,1,0,make_color_rgb(191,191,191),1);
depth = 1;
}
// Draw foreground blocks
if (data[# xx,yy] > 0) && (is_tile(data[# xx,yy])) {
var index = 0;
var col = c_white;
if index != -1 {
draw_sprite_ext(obj_item_control.block_sprite[data[# xx,yy]],index,x+xx*BLOCK_SIZE,y+yy*BLOCK_SIZE,1,1,0,col,1);
} else {
draw_sprite_ext(obj_item_control.block_sprite[data[# xx,yy]],0,x+xx*BLOCK_SIZE,y+yy*BLOCK_SIZE,1,1,0,col,1);
}
}
if global.see_lightmap = true {
if lmp[# xx,yy] = 0 {
draw_rectangle_color(x+xx*BLOCK_SIZE,y+yy*BLOCK_SIZE,x+xx*BLOCK_SIZE+BLOCK_SIZE,y+yy*BLOCK_SIZE+BLOCK_SIZE,c_blue,c_blue,c_blue,c_blue,false);
} else {
draw_rectangle_color(x+xx*BLOCK_SIZE,y+yy*BLOCK_SIZE,x+xx*BLOCK_SIZE+BLOCK_SIZE,y+yy*BLOCK_SIZE+BLOCK_SIZE,c_red,c_red,c_red,c_red,false);
}
}
}
}
Last edited: