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

1 decade ago by stahlmanDesign

@joncom - about this post I made from 2 years ago:

I have a giant world map that's 7168 x 6912 pixels. That's 7x9 iPad screens. It's too big, and that makes it slow, so I was thinking of breaking it up into regions that would load like a new level. But since I want it to be seamless, I want to be able to transition to the new level at any horizontal or vertical point. That means when the new level is loaded, I want the character to start at a specific point depending on how he came in. It doesn't work to have one fixed starting point, because you can enter the level from many different directions.

How should I deal with this?


I never came up with a solution, but I can imagine it as an array of arrays containing levels that if put side by side would appear seamless:
[
[a0,a1,a2,a3,a4,a5],
[b0,b1,b2,b3,b4,b5],
[c0,c1,c2,c3,c4,c5],
[d0,d1,d2,d3,d4,d5],
[e0,a1,e2,e3,e4,e5]
]

If you start at level c3, when the character gets to the left edge of that level, he runs into a loadLevel entity which loads level c2. The important part is passing the player coordinates and velocity to a global object in main.js (probably) so when level c2 is rendered, the player is at the same pos.y, but if moving left, the pos.x is on the right side of the level moving into.

In your levels you might have the player entity somewhere, but this would always be overridden if the player were entering from the top or side. That logic I would probably have in main.js

1 decade ago by Joncom

Thank you for your thoughts stahlmanDesign.

A couple requirements I have:
- Starting out with small maps, rather than splitting a big map into smaller maps.
- Small maps are not guaranteed to have the same width/height as each other.
- As the player reaches the edge of a small map, the next should be loaded ahead of time so that they appear to blend together as a single map.
- The player can be spawned in any given small map, and it needs to be known how to reconstruct the rest of the world from that point-outward.
- Bonus: Unload map resources for distant maps, to free up memory.

Because of the different map sizes, I'm not sure a 2D array of maps will offer any real advantage.

And because levels must load before they are within view, I suspect triggering a loadLevel entity at the edge of the map will be too late to achieve this effect.

Not entirely sure what approach I will take on this yet, but will be sure to update this thread with my findings as I progress. Suggestions welcome.
Page 1 of 1
« first « previous next › last »