Impact

This forum is read only and just serves as an archive. If you have any questions, please post them on github.com/phoboslab/impact

1 decade ago by Graphikos

I have a situation where I may need up to 500+ entities on the visible view. Is this just too much for the engine to handle or is there something I can do to increase performance? Even when nothing is moving the performance is cut in half.

The entities don't need to do much other than just sit there. I have them set as a FIXED collide so that they are solid.

I'd probably just create the background and CollisionMap... do the pre-rendering and all that good stuff but I need to be able to manipulate each tile during gameplay and you can't do that with background as far as I can tell.

Maybe do my own pre-rendering somehow of larger chunk areas and then swap those out for real entities when the player is near/in that chunk?

Any thoughts? Am I missing something simple (fingers crossed)?

Thanks!

1 decade ago by Graphikos

After seeing:
http://www.phoboslab.org/crap/notjsgamebench/

...there has to be something I'm missing! I should also mention that I have updated my graphics card driver to no avail.

1 decade ago by dominic

Most of the time, the performance is bound by the drawing speed. If you have a lot of entities on the screen at the same time, it will get slow eventually.

That said, sometimes the physics and collision detection can be the limiting factor. In the benchmark you mentioned, the update() of the Asteroid entities is overwritten with this:
update: function() {
	this.currentAnim.update();
}

Notice that it doesn&039;t call #this.parent() - so skips the entity movement (based on this.vel.*) completely. This makes the benchmark run a tiny bit faster.


Regarding BackgroundMap pre-rendering: you could hack (or subclass) ig.BackgroundMap to re-pre-render a chunk when you manipulate one of the tiles. I.e. each time the .setTile() method is called, figure out which chunk was modified and re-render it. Or just do your edits and then call .preRenderMapToChunks on the BackgroundMap to re-pre-render it completely.

1 decade ago by Graphikos

Dominic,

Thanks for the tips. I'd try the update tweak but while waiting for a response I've completely rewrote my code to try just drawing my own tiles and swapping relevant entities in and out. It feels like a much better what to go with things. Then I'd only have maybe 12 entities on the screen at any given time and the rest are just drawn tiles. Probably the same way the BackgroundMap works sans the chunking.

I don't know if there is any major bottlenecks/repercussions with spawning and killing entities all the time but I'm about to find out.

Thanks!
Page 1 of 1
« first « previous next › last »