I am developing a simulator based on a 2D mesh. Progress is good. Understood code very well over the last few days, and I had some problems today.
I build two rooms, set the position of the door and create a person. A person has 2 types of rooms that they must visit in order to recover (this is a remake of the Theme Hospital). I press the Caviar button, the face moves along the grid from the screen, and then, when the caviar is finished, they get their first way to the first room, then the second, and then back to the end point of the appearance.
When I say the appearance point, I mean the point from the screen / grid, when I say the end point of the appearance, I mean the point where the person, when the spawning cycle is finished, and they are completely on the screen / grid.
Now the problem arises, what to do with the "man" (which is an independent object), ends? Should I just set the boolean so that they cease to be "active", but the data on them remains? I was not sure, so I tried to simply remove them from the ArrayList objects of the people in which they were contained.
I did this by assigning a numerical value to each person at creation, which was the same as their new position in ArrayList, and then when they were deleted using that number. I know that flooring itself, but now I'm testing only one person. If anyone can help me with this, fantastic! But I suppose this is more of a question.
When a person needs to be deleted, they are there, and I check the size of the arraylist, and then I get the following error ... "Exception in thread" AWT-EventQueue-0 "java.util.ConcurrentModificationException"
I did some research, and I understand that this is due to the synchronization of objects in different threads, but I'm not sure that I have more than one thread. I have one timer, and I don't think ArrayList people are available elsewhere.
Any thoughts? Ideas? Suggestions? Comments on this?
Thanks in advance!
(I will post the video soon and update this question with a link to it)