Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm looking for terrain that gets removed in chunks (like in Worms, of instance). How do you do this in SDL?

share|improve this question
Liquid simulation and deformable terrain are not typically handled the same way. These are two separate questions with two separate answers. – Sean Middleditch Jul 7 '13 at 5:26
have you got either? – aboutstairs Jul 7 '13 at 5:29
The implication is that you should separate this into two separate questions so each can be addressed separately. – ssb Jul 7 '13 at 5:56
found this link after some googling, might be of use to you:… – ThatOneGuy Jul 7 '13 at 6:29
The graphics, sound and input of such a system are only a very minor part of the system. Check out some of the related questions to learn how you can do this:……… – Byte56 Jul 7 '13 at 12:59

Something like this usually utilizes simple texture operations. The basic promise: Use a texture as your map. If there's full alpha, you consider a pixel to be air. If there's not full alpha, you consider a pixel to be ground. Different thresholds can be set to achieve things such as transparency.

If you want solid drawn parts that are translucent or have different properties (like ice) you'll most likely want two textures: One to display, one for game logic. The game logic one could be as simple as an array of bytes, where each byte represents one pixel. You can then use bitwise operations to determine terrain attributes like solid, frozen, bouncy, indestructible, etc.

Overall, the whole thing is rather easy to realize:

  • Check pixels do determine whether they're solid (are visible).
  • For explosions simply draw filled circles of full alpha.
  • For gun shots simply draw lines using full alpha.
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.