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 mandarin

Hello!

I have started working on a game like the good old vertical scroller 1942 but am wondering how to do the levels.

At first I thought about writing a plugin that could generate levels on the fly, but since this project is just for fun I dropped the idea. I really like Weltmeister and find designing levels almost as fun as playing them. So I have for the moment settled on the idea of designing each level by hand.

The only problem I am facing is that I cannot seem to find a way to load two levels at once, and place them after eachother. I'd like it work like this: first level is loaded, and when the plane is getting near the end of the level the next level is loaded and placed on position level1.pos.y - level2.height. Level one gets deleted as soon as it has scrolled past the bottom of the screen.

Does anyone have any ideas on this?

Regards,
Thomas

1 decade ago by MyShuitings

I've got something pretty similar, but its a pretty nasty hodgepodge of entities and code in the main.js at the moment. It does just that. When you reach the edge, the entity triggers a new level, and scrolls accordingly (4 directions since mine is a top down sprawler Zelda: Link to the Past clone)

Lemme see if I can clean it up and package it up over the weekend.

1 decade ago by mandarin

That sounds great! I would appreciate to get a peek into your code. :-)

1 decade ago by MyShuitings

I didn't get a chance to work this weekend (sick kids), but I'll package up something here this evening.

1 decade ago by xdissent

Try reading through this thread: http://impactjs.com/forums/help/spawn-entities-just-outside-of-players-view

Might be something similar to what you're looking for.

1 decade ago by mandarin

xdissent: Thanks for the tip! I had read through that discussion before without noticing that it could be applied to my situation.

I have done some tests and I managed to load the next level as I hit a trigger entity.

At first I didn't reset the entity list, which resulted in entites from level 1 appearing in level 2. I created a custom function for deleting all other entities than the player before loading the next level. That worked fine. I also did a variant where each entity has a check function which checks the entity's pos.y, and when the entity scrolls past the screen it kills itself.

I think I'll stick with checking once every level change. It's not necessary for each entity to check it's position for ever tick.

One of the first lines in the loadLevel function from game.js resets the screen position. I altered that line to fit the size of my levels, but it only worked once. As i passed level 2 and entered level 3 the scrolling stopped and the plane flew out of sight. Still trying to figure out this one.

Another thing I noticed was that the trigger entity that came with the Biolab Entity Pack triggers several times. I understand how it was meant to work, and by reading the code I still haven't figured out why it doesn't trigger only once. This causes the main game class to load the next level a bunch of times.
Page 1 of 1
« first « previous next › last »