Ok, so we'll call the foreground, terrain.
A terrain would at least need two members: an array with pixel data, and a 2D array related to the other by location that holds wherer a pixel is passable or not. When I say "related by location", I mean that the array element [x][y] is applied to the pixel [x][y].
To fill your arrays, you need an image. Let's take this for example:
http://img391.imageshack.us/my.php?image=samplecw4.png
What you would do first, is load this image into memory. Then you go through each pixel and check if it matches your chroma key. If it does, you set your passability array element accordingly.
Once this is done, you copy your terrain to the screen pixel by pixel. If the pixel should be passable, you don't copy it, otherwise you do.
Now you have the destructible terrain (it is destroyed by setting elements on your passability array and hiding pixels on the screen). You only need to write the algorithm that will allow your worms to move, or not.
Keeping the worms from falling through is easy. It harder to make them move. First you need to set a maximum climbable height:
Your borders will only
look soft. From the point of view of the program, they will be full of steps.:
.............#....................
...........###....................
##################################
Your worms need a maximum climbable distance to avoid embarassing situations. They will also need to realize if there's a tunnel that's too short for them:
.....####################
.....####################
.....####################
......................... <-- The worm should not be able to walk here.
.....####################
And they should also get on top of layers:
.........................
......................... <-- The worm should step on here.
.....####################
.........................
.....####################