2D gaming performance

:sunrise_over_mountains:
I encountered a performance problem.

My goal is to generate: ground, NPCs, background.

I started with ground generation. As soon as the script detects that a black screen will appear soon, the script generates ground.

For now, I settled on the ground generation approach (piece of ground->bridge->piece of ground)
At first I wanted to attach the code, but I think it would be better to try to explain the meaning of the generation.

generation option: 1

  1. create an array
[
0[{x,y},{x,y},{x,y}],
1[...]
...
]

Then I generate nodes (sprites) from this array and add them to the playing field. There are several nodes in one line. This approach turned out to be expensive 12,999 triagle and 2 FPS

generation option: 2

  1. create an array
[
0[{x,y},{x,y},{x,y}],
1[...]
...
]

Then I generate nodes from this array, but use the TILED type for the sprite and generate one sprite in one ground line and stretch the sprite in width. Got 3,490 triagle and 4 FPS.
Screenshot 2024-05-01 at 14.11.23

Can anyone tell me what ways to improve performance? Is it possible to make a platformer with automatic landscape generation lasting 5-10 minutes?

FPS has become better. The problem was that I did not clear one of the arrays.

[
0[{x,y},{x,y},{x,y}],
1[...]
...
]