Mouse OnClick with explosion effects

Started by
0 comments, last by deftware 9 years, 6 months ago

Hi everyone:

I'm doing a effect like when I click in then window somewhere, there will be a explosion effect. But, here is a requirement : When I continually click on different position, the previous explosion effect should not disappear immediately, I mean they should be work on there own life span.

The first of my solution is that I build a render queue and a position queue. However, it doesn't work. Because it cannot render the current mouse position explosion effect when previous explosion effect is still working.

So I tried to create a thread when I click. And I hope each thread could finish one explosion effects. But there must something wrong when I call the Draw() function, because Draw() is also called by gluDisplayFunc(Draw);

Does anyone have solution ? Thank you very much.

Advertisement

create a little array of explosions that contains their position, and lifetime, or time of creation. Then every frame you just draw all the active explosions in the array that haven't burned up yet. When you click, you find an empty/dead explosion slot in the array and fill it with the mouse position and current time.

This topic is closed to new replies.

Advertisement