0
\$\begingroup\$

I have a processing game where I am having serious lag problems with collision detection. I am using the most effective code I can think of however after about 9 levels in The game gets unbearably laggy. I would show you the code but site wont handle my less thans.

If you want to check the program out you can find it here: https://www.khanacademy.org/computer-programming/tanks-v1245/6637554186715136 under the tankMelee function ~line 160

\$\endgroup\$

closed as off-topic by Lars Viklund, MAnd, Kromster, Alexandre Vaillancourt, Seth Battin Jan 22 '16 at 2:51

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions about debugging a problem in your project must present a concise selection of code and context so as to allow a reader to diagnose the issue without needing to read all of your code or to engage in extensive back-and-forth dialog. For more information, see this meta thread." – Lars Viklund, MAnd, Kromster, Alexandre Vaillancourt, Seth Battin
If this question can be reworded to fit the rules in the help center, please edit the question.

1
\$\begingroup\$

Most games use quadtree structures to manage the colisions, you should read about it.

Anyways, if you are having lag after X levels is possible that you are storing all the objects and checking them out every loop, and not just the object in the current scene or level.

\$\endgroup\$
  • \$\begingroup\$ but this is a real time thing - the enemy has to check for bullets, walls ,and the player, the lag after levels is a "I have to check more things" issue \$\endgroup\$ – gfaster Jan 17 '16 at 22:38
  • \$\begingroup\$ Understood, have a peek in the link i provided, theres a demo cheking docens of objects un real time, quadtree is used in real games, give it a try \$\endgroup\$ – PRDeving Jan 18 '16 at 8:34

Not the answer you're looking for? Browse other questions tagged or ask your own question.