I was watching this video when i couldn’t seem to figure out how he did it?
It seems to me that his population count and the actual entity count is skewered, that is the population count is much larger than the actual number of entities. I noticed his population kept ticking up at a constant rate, which gave me the impression that it’s a lot larger than the real population.
Your only question was related to that video, so my answer is above. If you have other questions (related to maybe another game or your own) do ask! :point:
EDIT: I should clarify a bit more. His entity count isn’t anything too extreme, it seems like it’s no more than a few thousand real entities at a time which is do-able. Notably he doesn’t have entity-to-entity collision. If you do have entity-to-entity collision the computation time will increase exponentially.
Yeah I knew that already but what i want to know is how would you optimize having lots of entities
for example in my tile renderer i use a multidimensional array to store my tiles and then i use the camera pos + camera. width to figure out what I am rendering instead of looping through all of the tiles to see if they are inside the window. I was wondering is there a way i could do this with entities?
“Having” lots of entities and “rendering” lots of entities are two separate things. I assumed you were talking about the general optimization of having a lot of entities rather than controlling when to render an entity if it was on-screen.
A way to cull entity rendering is to use an invisible rectangle that is the screen object. You’ll have to loop through all the entities and if they collide with the rectangle (using basic math) you can render them. Yes, you have to loop through all the entities but it’s much better than rendering each one regardless if they were on screen.
Unless the entities are stored spatially, such as in a grid. Then you only have to check cells that will be on screen. The same can be done for the tiles as well, since they are spacial, as chris said here and ags elaborated on: http://www.java-gaming.org/topics/2d-minecraft-like-game-rendering-issue/36416/msg/345426/view.html#msg345426