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

5 years ago by anasbud

Hi,

I have a big map where I place 430 entites in it. They are maybe 4 or 5 differents entities.

The problem is that the game is a bit slow on some devices...

Here's what my map looks like : http://i.imgur.com/7LOgYQ9.png

The red square is the user's screen.


How can I do to optimize the game ? I thought about a kind of blocking the init method until the entity is x pixel of the player... but it seems that it's not working.


Any help ?

5 years ago by pattentrick

Hi there,

it's difficult to give you an answer without knowing some basics about your game mechanics. Do you place all of your entities manually in Weltmeister? How do the 450+ entities behave? What do they do in the game? Can the player somehow interact with the entities that are off screen? Can the player move back and forth?

A wild guess: Instead off having hundreds of entities off screen, just spawn a couple of entities once you are near a certain area and remove those entities once they leave the screen. This way there would only be a couple of those entities at a time, instead of 450+.

Do you use Impact++ on this project?

http://collinhover.github.io/impactplusplus/

If yes, you could set the performance of those entities to static. Static entities skip a lot of checks and other method calls. Because of that the performance improves a notch. There is even a highPerformace property:

http://collinhover.github.io/impactplusplus/ig.EntityExtended.html#highPerformance

But you will lose some functionality and flexibility when your are using this.

5 years ago by anasbud

Can I in some way make impactJS not handling the entity until it becames visible on the screen ?

5 years ago by pattentrick

You could skip the logic at the update/draw methods as long as the entity is not on the screen with the help of a flag:

// your entity class ..
isOnScreen: false,

update: function(){
    if( this.isOnScreen ){
        this.parent();     
    }
}

But you would still need to add a mechanic that sets the flag to true or false, depending on if it's on screen or not. However, i think it's a bad idea to have hundreds of entities in your game when you don't need them. You should spawn and remove them dynamically. That said, i can't give you any good advice as long as you don't share more informations on your game mechanics.

5 years ago by Joncom

Quote from anasbud
Can I in some way make impactJS not handling the entity until it becames visible on the screen ?
In your entity update function, just return if the entity is off-screen. Effectively this means you'll have entities which are completely frozen until the player approaches them. This could be a significant resource saver.

Edit: The game Dark Souls uses a similar technique.
Page 1 of 1
« first « previous next › last »