In had a project with about 4000 sprites named "block". They were spawned automatically with events.
I had multiple nested loops with "pick by comparison" or "pick by evaluate" on "blocks"
pick blocks by…
-> function "search"
function search : "pick blocks by evaluate"
On my first loop : no problem
Second nested loop : no problem
Third and last nested loop : micro-freeze during this loop, which was just a simple "pick by comparison".
So I thought one tick was not enough to do something like : search for theses blocks inside 4000 blocks. Among these found blocks, for each of them, test for surrounding blocks inside 4000 blocks… etc.
So I guess it was pretty normal if it was kinda slow.
However, I modified my events to replace my blocks by tiles from a tileset object (same number of tiles as blocks : about 4000).
It appeared that nested loops to search specific tiles was a lot faster.
I discussed it with a programmer friend. I have some basic programming knowledge but he's more skilled than me so I listened to him .
Basically, he said that picking some objects by an evaluation or comparison among a lot of objects can be slow or fast, depending of how they are "organized" (not sure if it's the right word, my english isn't as good I'd like). If the objects are sorted in an array with for example their coordinates, well, looking for one object among 50000 other ones will be very fast.
In Construct 2, my nested loops with sprites were slow.
Same loops with tiles were very fast.
So I supposed that it was because the tiles are sorted in an array, somewhat as a grid, so looking for one or more specific tiles is very fast.
Is that right ? Could you explain the fundamental differences between tiles and sprite regarding performances and how Construct 2 gets access to them ?
I hope my message is understandable. Hard to explain technical things with my english !