Hello Internet friends, I am making an indie game (commercial to be able to continue paying for my university) with nodejs, phaser, mapeditor.org, js + ts and electron (electron will apply it at the end).
I have previous knowledge with Reactjs so I use a similar philosophy and I do most of the things in functions, I only apply the classes when creating scenes, the rest is pure in functions. So far, in one scene I load all the images and sources and in another the music, so far so good, its database (localstorage) works fine and I have several slots.
For now the game runs at 60 fps I already made the entire interface and the game itself is in its final phase, I only need the physics phase, that phase is obviously the character and its mechanics, enemies and the map, collisions and all that physics, I have been making the game and at the same time learning phaser I have already created the collisions with the character and the map in drafts and it works, but when I started applying it in the game itself I started to have performance problems.
I know nothing more about hardware than the essentials, I have an Intel (R) Core ™ i3-3220 CPU @ 3.30GHz and 8 GB of ram, in addition to the fact that my graphics card is amd radeon hd 5450, my computer has its time , pages like github their portal that has an animation I run at 10 fps, the game the rendering is canvas because webGL runs me at 10 fps.
I have avoided the use of webGL and have limited myself but still I have achieved what I had in mind, when I started to create the map with the tiled I used 4x4 with 300 patterns and the game was running at 10 fps, I increased it to 8x8 and the fps increased and finally I stayed with 32x32 and stayed at 60fps to make sure I filled the entire image map and everything normal, I am not sure why while increasing the dimensions increases the fps, I began to decorate the background in their respective layers and began to use this code in update.
Create
/* - map - */
ln9z1lvx = this.add.tilemap("map_ln9_zn1_lv0");
lv0Tileset = ln9z1lvx.addTilesetImage("tileset_ln9_zn1_lv0&lv1");
lv0TilesetEvents = ln9z1lvx.addTilesetImage("tileset_ln9_events");
/* - layer - */
ln9z1lvxLayer[0] = ln9z1lvx.createLayer("backgroundZ0", lv0Tileset, 0, 0);
ln9z1lvxLayer[1] = ln9z1lvx.createLayer("backgroundZ1", lv0Tileset, 0, 0);
Update
if (controls.left.isDown) {
/ * * /
ln9z1lvxLayer[1].x = ln9z1lvxLayer[1].x + 0.01;
}
But I noticed that the phaser scrollFactorX
function did the same I do not know if it is correctly, but as soon as I applied it it began to drop to 45 fps, and the more I add layers, the lower the fps, I want to emphasize that I only have that function in update. So I still need to add the enemies, traps, objects and their respective animations and that has already worried me, because it is not that I am doing a great thing to lower the fps so much, so or am I doing something wrong with the code that I doubt it because until now everything worked fine until I got to the part of the collisions or in a few words my computer is already dying.
I suppose that my computer is not working correctly, but I have come to ask you for advice, to avoid all possible fps drops and some tools to evaluate the performance of the game, I understand that the same browsers have them, but I want the advice direct from this community that uses this great engine.
I apologize for the will, but I try to be the most specific and if you want more details I will give it to you, I am sorry for the bad translation, my native language is Spanish.