Need help understanding if there is something wrong with my code. I want to randomly spawn premade levels for an ebdless runner, but my levels don't spawn on the position I want them to. I'm trying to spawn them right after the previous one ends, by taking their length in pixels and calculating where it ends, to spawn the next level at the ending coordinates. This is my current code (I apologize for the messy code):

These are the variables declared. There is an array declared that stores the two different levels.

This is where the length of the next spawning level is taken.

This is where the level is spawned with an offset of the size of the previous level. one of my levels (6000x1500px) spawns at the correct offset.

but the other level (6000x1215px) doesn't spawn at the same offset as its size, even though the offset is taken from the levels dimensions.

start of the level.

end of the level.
I don't understand why this is happening and would appreciate the help.