Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

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
1  
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: web.archive.org/web/20090101215451/http://blog.xna3.com/2007/12/… –  user1895420 Jul 7 '13 at 6:29
2  
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: gamedev.stackexchange.com/questions/6721/… gamedev.stackexchange.com/questions/11840/… gamedev.stackexchange.com/questions/18173/… –  Byte56 Jul 7 '13 at 12:59

1 Answer 1

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

 
discard

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.