Example – game bonus

See also: Examples List
This functionality is available as WordPress Plugin.

Faucet can be used as a game bonus as well.

This example is based on nice 2D breakout game using pure JavaScript.
Feel free to use several different faucets for different bonuses, depending of the game results. Look at the Faucet List – most likely you will find more JavaScript games there, so it may be useful to take a look at the source code. 😉
You can also experiment with jsfiddle copy.
By the end of the game you can switch to the faucet view by using jQuery, something like:

function ShowFaucet()
{
    game_in_progress = false;
    jQuery("#game_wrap").fadeOut('slow',
        function(){ 
            jQuery("#faucet_wrap").fadeIn('slow',
               function(){
                jQuery("#faucet_wrap").html("<div id='wmexp-faucet-123456'></div>");
                wmexp_render_faucet_123456();
            }) 
     });
}

Or pure Javascript:

function ShowFaucet()
{
    game_in_progress = false;
    document.getElementById("game_wrap").style.display="none";
    document.getElementById("faucet_wrap").style.display="block";
    document.getElementById("faucet_wrap").innerHTML = "<div id='wmexp-faucet-123456'></div>";
    wmexp_render_faucet_123456();
}

more examples