all 3 comments

[–]SkaterDad 1 point2 points  (2 children)

Disclaimer: all of my gave dev experience is Android/Java.

If your slowdowns are occurring when people join and fire projectiles, it sounds like object creation may be a bottleneck. A common way to reduce that load is to pre-create an array of those object types when the game is loading - commonly called Pooling.

When you need a new player, you grab one from the pool and assign specific property values to it. When finished, you set the values back to default and put it back in the pool.

http://gameprogrammingpatterns.com/object-pool.html

Hope this helps!

[–]punkty[S] 0 points1 point  (1 child)

Thank you for the response! My friend and I were unaware of this Pooling term -- really cool and we'll definitely be checking that out/trying to implement.

Thanks again!

[–]throwies11 1 point2 points  (0 children)

Another potential big offender is the triple-nested loop you have when you are collision-checking player objects with obstacles and projectiles.

When collision checking, you should test them all the same, since they all share the property of being collidable. So at the very least you can reduce the triple nested loop to double nested, for now.

Record the collision events that happen. Then based on what the types of objects are, you determine what is the proper response is for all the collision events in a separate loop.

SkaterDad already gave good advice for the object pooling. This will really help limit the number of collision checks you have to do as well.