Problems with Rendering Multiple Entities

Started by EB5473, July 05, 2012, 21:21:59

Previous topic - Next topic

Fool Running

It looks like Entity.tick() can remove itself from the entities list? If that's the case, then you would need to keep a separate list of entities that were deleted and delete them after running through the tick() loop. Alternately, if an entity can only ever delete itself, you could do a reverse 'for' loop (instead of a foreach) which would keep the removed item from affecting the tick() loop.
Programmers will, one day, rule the world... and the world won't notice until its too late.Just testing the marquee option ;D

EB5473

Only problem I can see with that is the fact that it would seem EVERYTHING needs to run through the tick() loop to actually run. I'll see what I can engineer, and maybe I'm not understanding it quite right, but let's see.
Coder, Mastermind, Friend

EB5473

I'm not figuring it out. Anyone else have an idea on how to fix this?
Coder, Mastermind, Friend

CodeBunny

This question seems to have morphed. Can you restate the issue you're working against now?

EB5473

Sorry, your right...
I'm working against a ConcurrentModificationError
Coder, Mastermind, Friend

basil

you have probably a nested remove() in a iteration over the list itself.

you can use a list or set that works with concurrent access or you have to que all read and write properly in you game loop.