GLOGIC 20 wrote: > hi its in 2d.. > this is what i have at the moment and it will do the job i suppose. > Basically when a collsion occurs startexplosion is called to initialize the > values needed, such as the position of the ship and random directions to > move in, live span of each particle. each time updateexplosion is called > from a timer it moves each bit in the velocity it has and decrements the > live of the particle. > any ideas of how to improve it? or a better way to tackle it even? > oh and any idea how to stretch an image to set as background of the form? > thanks > gav
One way to improve it is to decrease the velocity exponentially. Think about it: Explosive debris is thrown from the ship at some velocity but that velocity is going to change over the lifetime of the object because the explosive force dissipates as you move further away and things like friction and gravity come into play to slow the object down. Downside to doing this is you'll have to use more particles and bigger velocities and you'll be recalculating the velocity every iteration (i.e. more CPU). Upside is you get more realism. And every gamer I know loves a satisfying explosion. Another option to explore is multiple explosions. Perhaps a few smaller ones at different points along the ship and then a big one. Consider using a variety of colors. You're using green explosions...an odd color choice, but try variations of a few surrounding hues for each particle. It'll make the explosion more lively. Also, consider varying the size of each particle at little - put a small filled circle at the end of the explosion and make it slightly brighter than its tail. As to the implementation, it is decent (I don't think it is complete/working, though). newpos should probably be moved to the code, though, to save structure space and potentially improve performance. Not that you've got a performance issue, but particle engines can chew lots of CPU/GPU cycles. Consider letting a GPU handle your particle engine's drawing operations. 2D is just a special case of 3D. There are several 2D games made using a 3D engine. GPUs are designed for this sort of thing. That way you can worry about the physics of the explosion and not how it is drawn on the screen - let the GPU worry about that. -- Thomas Hruska CubicleSoft President Ph: 517-803-4197 *NEW* VerifyMyPC 2.4 Change tracking and management tool. Reduce tech. support times from 2 hours to 5 minutes. http://www.CubicleSoft.com/VerifyMyPC/
