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

10 years ago by henonchesser

Javascript is single threaded right?

So if I have Entity A, Entity B, and Entity C. And they each have a function to move one space to the left but only if the entity preceding them alphabetically has moved as well. And lets just say Entity A can move on it's own. Will Entity B and C not move because A is moving in the same update cycle?

Or does Impact loop through all entities in order so that Entity B's update would come after Entity A's update and know whether or not to move?

10 years ago by stahlmanDesign

Since each entity has an update method, all entities move and are checked for collision. Once all have moved and either bounced back due to collision, or have been able to freely move, then the draw method draws them all.

It is not done in alphabetically order, but by zIndex. You can change the zIndex of an entity and then call sortEntitiesDeferred before doing your calculation. This may be necessary if you want to calculate some entity before another one.
Page 1 of 1
« first « previous next › last »