stopviolence Posted March 18, 2016 Share Posted March 18, 2016 I must develop a game with a very large level, with about 500 objects inside. How will Phaser manage the stuff ? - does Phaser perform a stupid brute-force test on my 500 objects to check if they're out of screen, and so kill players' CPU ? - does Phaser stores cleverly my 500 objects in a spatial structure (like grid,quadtree...) to make a fast search on local objects ? Thanks to help me. Fntastic 1 Link to comment Share on other sites More sharing options...
drhayes Posted March 18, 2016 Share Posted March 18, 2016 Pretty sure Rich answered in this thread: 500 isn't that many objects. I think you'll be fine. Link to comment Share on other sites More sharing options...
stopviolence Posted March 19, 2016 Author Share Posted March 19, 2016 No, this other topic was about physic engines. Now, my question is about - the graphic engine - objects routines. What i want to do is make 100% sure that out-of-screen objects use 0% cpu. Link to comment Share on other sites More sharing options...
drhayes Posted March 21, 2016 Share Posted March 21, 2016 No, those offscreen objects will still use CPU. There's no way to stop that, though. If they didn't use CPU to update themselves you wouldn't know when they were coming onscreen from offscreen. For most games, rendering is the most expensive operation vs. any game logic you do. And I'm pretty sure that Phaser's rendering engine makes use of WebGL such that the graphics card will not waste time rendering anything offscreen. Offscreen culling is way faster in the GPU than in the CPU, anyway. Spatial hashes are much more of a physics engine thing than a graphics engine thing, I think. Try testing your game and see how much CPU it uses with offscreen objects, see if it's acceptable. Link to comment Share on other sites More sharing options...
stopviolence Posted March 30, 2016 Author Share Posted March 30, 2016 Thanks for informations. I made my last game without phaser, developed from scratch, it uses the old-school method of object pool generators in a large tilemap, so offscreen objects just doesn't exist. So i think i should keep this method for games with very large maps. Do you know a javascript game library working that way ? Link to comment Share on other sites More sharing options...
dimumurray Posted March 30, 2016 Share Posted March 30, 2016 38 minutes ago, stopviolence said: I made my last game without phaser, developed from scratch... Did the last game you created leverage GPU acceleration to maximize rendering? You get that out-of-the-box with Phaser. I think Phaser's implementation exploits (OpenGL) clipping options so that objects are not rendered off-screen, so unless those objects are used in a context independent of rendering (like physics for example) you don't have to worry about object pooling. All the rendering stuff is handled internally (and efficiently) by the GPU. I'd suggest you take drhayes advice and test it for yourself. You can try one of the bunny mark tests or create your own. Link to comment Share on other sites More sharing options...
Fatalist Posted March 30, 2016 Share Posted March 30, 2016 GPU does culling but sending the vertex information still takes time. So it does make sense to do culling with a spatial structure on the CPU side if there are many times more hidden objects than visible ones. 500 objects is too few though. Link to comment Share on other sites More sharing options...
stopviolence Posted April 3, 2016 Author Share Posted April 3, 2016 I was not talking about gpu but about cpu. P.S. (it wasn't the point but i'd like to add that: for a small sprite, a gpu-drawcall is more cpu-intensive than a cpu-blitting) Link to comment Share on other sites More sharing options...
Recommended Posts