Jump to content

Performance tips?


Recommended Posts

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: 489674641_.thumb.png.a6ae45419f259b8e404cb04600c15daa.png 

oh sorry there should be negative y: -15000 


Edited by doqsoftware
Link to comment
Share on other sites

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.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...