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 dddaaammmooo

hi all,

i am wondering what the best way to handle pickup objects in the game is? in my endless runner i have a level which contains hundred of hearts that the player can pick up as they run along. if i place these objects in weltmeister they all get spawned into existence at the beginning of the level and there are hundreds of entites being updated every frame even though they're only ever visible for a few seconds of the game.

i have other entities such as flocks of 30+ birds whereby i have a control entity that spawns the individual bird entities just off screen as the player approaches, and then the birds get killed as the go off screen again. however in the case of pickup items i need them at very specific locations so this doesnt really seem practical.

is there a better way to handle their creation?

1 decade ago by Joncom

This depends on how you go about making the level "endless". If your player keeps getting shifted back to the beginning of the level, again and again, then perhaps set the pickup-items at specific places. And then when they are collected, don't actually delete them, just mark them as collected, set them as invisible, and start a timer.

When the timer has run out, make the item visible again, and mark it as "collectable" one more. But the player will be so far gone that this will happen off-screen.

1 decade ago by vincentpiel

If i were you i would handle the bonuses of your game this way :
- keep on using the editor, since it is handy.
- when level is loaded, remove all entities except player.
- store them within an array, sorted on x in reverse order.
- every update of the game, pop() as many items as needed so they will be spawned when the player can see them.
- when items goes out on screen on the left, have them killed.

It is also a good idea to use a pool, since you will re-use some objects a lot.
http://impactjs.com/forums/code/pooling-impact-js-classes/page/1#post24045

Pooling would help the 'hearts' as well as the 'birds' not to create garbage.

Btw the link to your game is broken :-(
could you restore it ?
what is the name of the singer ?
and maybe post also the media of your game with the code so we
can fully test it ?
Thx.
Page 1 of 1
« first « previous next › last »