doqsoftware Posted April 29, 2021 Share Posted April 29, 2021 (edited) Hi there! I'd want to ask for some performance tips if possible. I'm trying to create game like agar.io. I have 15000x15000 map filled with objects. The game has 2 types of objects: cell and food. The whole map contains ~3500 food objects and up to 500 cell objects, food has one texture for all sprites and is rendered using ParticleContainer while cell using just a Container because it contains some additional sprites in it (name, mass etc) BUT has one texture for all sprites as well. So i have some questions: 1) Is it worth moving cell to ParticleContainer and then create an additional container for name and mass and then calculate its position related to cell? Name and mass always have zIndex > Cell. 2) A player has viewport 1920x1080 so only 1/10 of map should be rendered (it is like 300 food and 30 cells) but viewport size will be multiplied by player size offset so bigger player -> bigger viewport. Now my solution looks like: a) calculate bounds of viewport b) loop through every object and if it is out of view set object.visible = object.renderable = false. Is it alright or there are better ways? Here is visualization of what i'm talking about: oh sorry there should be negative y: -15000 Edited April 29, 2021 by doqsoftware Quote Link to comment Share on other sites More sharing options...
jonforum Posted April 30, 2021 Share Posted April 30, 2021 (edited) yes , it the good way "object.renderable = false." for every object not in the viewport (culling ). You can also look overthere for get more inspiration.https://davidfig.github.io/pixi-cull/ Edited April 30, 2021 by jonforum Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.