Ulbast

Finished, playable game with link, but code....

Recommended Posts

Hi, I present you my game made in Phaser, here u are:

redplanetgame.prv.pl

I've finished it 3 months ago. It's a platform game, to collect all goals and kill enemies. When I was creating it, it worked fine, I mean, on full fps, but when I reach the end it drastically slowed down. I started few topic about this problem.

 I think, it's too many bullets or sth.(or my weird structure of code). When u inspect the browser, on bottom u can see all of my phaser code I've used. It's this:

<script type="text/javascript" src="functions.js"></script>
         <script type="text/javascript" src="create.js"></script>
         <script type="text/javascript" src="update.js"></script>  
         <script type="text/javascript" src="game.js"></script>
    <script type="text/javascript" src="jquery-3.2.1.js"></script>

My question is: how to speed up whole game? Now it's seriously problematic.

Another weird thing is that on many computers it works fine, on few it doesn't run completely (black screen instead of game), on other it freezes after few seconds, and in one the space+left arrow is not working xD

Share this post


Link to post
Share on other sites

Thanks for your answers. Rendering from atlas is somehow complicated for me, the clearest , official tutorial have no basic explanation of it. But I've found a thing, that could be crucial here. Too many collisions handlers. Well I need them to control whole game, to call all essentiall functions, but they sloooooow game from 60 to 30 fps.

game.physics.arcade.collide(bullets, layer, resetBullet);
    game.physics.arcade.collide(grenades, layer, resetBullet);
    game.physics.arcade.collide(ebullets, layer, resetBullet);
    game.physics.arcade.collide(chest3, chest5, chesting);
    game.physics.arcade.overlap(bullets, ebullets, resetBullet);

It's for bullets to destroy chests, bullets with themselves and chest with chest. If I delete this, FPS goes from 30 to 60. But I need this. How can I do it? It's interesting, because the bullets aren't even created and they are slowing game

Share this post


Link to post
Share on other sites

from my experience, and plenty of other people's experience, it is 'bullets against bullets' that is causing your problems.

 

If you can, disable that type of collision. If you absolutely must have bullets against bullets or other things, consider making less collisions anyways (maybe bullets only collide before 1 second has passed away, or only if your level is high, etc)

 

In general, avoid collisions as much as you possibly can.

Share this post


Link to post
Share on other sites

There's a problem with all of your "blocks" arrays.

overlap(ebullets, grenblocks, collision_handler);

E.g., in grenblocks, indices 1 through 302 are undefined. Phaser treats Group vs. undefined as Group vs. itself. So it will collide the ebullets against itself 300 times, sorting it each time, all for that one overlap call.

If you use an array, it has to be dense:

[
  0: Sprite
  1: Sprite
  2: Sprite
]

Better yet, use a separate Group instead.

badarray.png

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.