Sign in to follow this  
Trillian

destructible landscape in 2D

Recommended Posts

Hello! I'd like to create a game a bit like this tank game but I need help on how to set up a system to have some destructible landscape (like in worms). I've tought of some ideas : 1- Have a texture, when there's an explosion, iterate through its pixels to remove a circular set of pixels (make it transparent). For collision, read if the pixel is transparent or not. 2- Have some geometry modified with the explosions, but I'd really get lost with the triangle computations... If you had to do it, what kind of technique would you use? oh and I've posted this in directx because I'm using DX9 and if you want to give me some code samples or links, I prefer tm have them for the dx api.

Share this post


Link to post
Share on other sites
There is a similar game called Pocket Tanks(great game, btw) and it actually looks like they used a particale system. It's hard to explain why it looks like they used a particle system, so I would recommend just playing the demo and drawing your own conclusions.

-AJ

Share this post


Link to post
Share on other sites
I would use the first method. The second would cause all sorts of problems, as you said with the triangle computations.
I'd advise splitting your texture into smaller chunks, so you don't end up with one huge 1024x1024 texture, and waste space. Several 256x256 or even 512x512 textures would perhaps be better.
So long as you use a dynamic texture (D3DUSAGE_DYNAMIC), performance shouldn't be that much of an issue; that's usually how things like procedural textures and clouds are done.

I'd advise keeping an a copy of your opacity in an array in system memory too; that would mean that you don't have to lock the texture for reading collisions, and reading from a texture (dynamic or not) is slow. So, whenever you lock your texture for updating the terrain, you'd also update your array. You could use a bitfield for that, but an array of bytes would probably be more efficient, and would allow you to flag pixels as being empty, solid, containing player 1, containing player 2, etc.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this