Your best bet is just to have an invisible object that always has the same X-Y position as the player so long as a flag is turned off. When the flag is on, have it randomly position itself at player x +/- random(intensity of shake), and player y +/- random(intensity of shake) a couple times. You could also control this by having it not shake when an alterable value is zero, then have an explosion add 10 to the value... when the value is greater than zero, trigger the shaking routine (explained earlier). Make sure you have the counter decrease by one every 1/20 of a second (change this for however long you want the screen to shake). There's a million ways to do what you're wanting to do, but that's how I'd go about it.
[edit], forgot to mention that if the flag is on or the alterable value is greater than zero, you'd need to center the screen on the shake object rather than the player.