Explosions / moving particles

Im programming a some sort of a game where explosions occur when two game characters collide.

I have tried to deal with this problem by making a seperate thread for every explosion, but the problem is, that the threads cant draw into the main window unless the main window calls them. Which would require an array of those explosion threads and it would not be a good way considering the memory.

So. How are the explosions/moving particles/occassionally happening things handled in real games?

I tried already search from this newbie section, but there wasnt any in first 10 pages… So any links to forums/tutorials etc.?

edit: or if anyone knows something about how for example enemies are added in game if the amount is not known while programming, it might be close enough so I could find the answer.

Have an Explosion objects which contains the data for a list of particles making up the explosion, and any resources it needs to manipulate those particles. Add an update(float delta) method that contains code to update the particles based on change in time (delta).

From the main thread cycle through all the explosions currently created calling update() passing in the time since the last frame.

Polling instead of threading.

Kev

Thanks. That sounds brilliant. Ill tell how it worked out once I get chance to test it in action (hopefully in few days).

edit: Yes, thank you really much. It works now without threads :slight_smile: