Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Auto Save

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <!DOCTYPE html>
<html>
<head>
<meta name="description" content="Mouad MELLAL Heavy Metal Monster" />
  <meta charset="utf-8">
  <title>Mouad MELLAL Heavy Metal Monster</title>

</head> 
<body>
  <canvas id="mycanvas" width="1335" height="665"></canvas>
  <center><button id="bouton1" onclick="play()"><img id="bgbutton" style="width: 35px;height: 35px;" src="http://i418.photobucket.com/albums/pp261/mine559/lg_guitar.png"/>  <span id="sp"><b>Start</b></span></button><button id="bouton2" onclick="pause()"><img id="bgbutton" style="width: 35px;height: 35px;" src="http://i418.photobucket.com/albums/pp261/mine559/lg_guitar.png"/>  <span><b>Pause</b></span></button><button id="bouton3" onclick="stop()"><img id="bgbutton" style="width: 35px;height: 35px;" src="http://i418.photobucket.com/albums/pp261/mine559/lg_guitar.png"/>  <span><b>Stop</b></span></button></center>
 
  <audio id="acdc" preload="auto" loop> <source src="https://mainline.i3s.unice.fr/mooc/HighwayToHell.mp3" preload="auto"/> </audio>

                                                                                                   
</body>
</html>
              
            
!

CSS

              
                #mycanvas{
  margin-left: auto;
  margin-right: auto;
  border: solid black 4px;
  background-color: #cfc8b5;
  background: url(http://i.imgur.com/exiwzsl.png);
  background-repeat: no-repeat;
  background-size: 100% 100%;
  width: 75%;
  display: block;
}

button{
	-moz-box-shadow:inset 0px 1px 0px 0px #383732;
	-webkit-box-shadow:inset 0px 1px 0px 0px #383732;
	box-shadow:inset 0px 1px 0px 0px #383732;
	background:-webkit-gradient( linear, left top, left bottom, color-stop(0.05, #000000), color-stop(1, #544e54) );
	background:-moz-linear-gradient( center top, #000000 5%, #544e54 100% );
	filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#000000', endColorstr='#544e54');
	background-color:#000000;
	-webkit-border-top-left-radius:0px;
	-moz-border-radius-topleft:0px;
	border-top-left-radius:0px;
	-webkit-border-top-right-radius:0px;
	-moz-border-radius-topright:0px;
	border-top-right-radius:0px;
	-webkit-border-bottom-right-radius:15px;
	-moz-border-radius-bottomright:15px;
	border-bottom-right-radius:15px;
	-webkit-border-bottom-left-radius:15px;
	-moz-border-radius-bottomleft:15px;
	border-bottom-left-radius:15px;
	text-indent:0px;
	border:4px solid #000000;
	display:inline-block;
	color:#ffffff;
	font-family:Arial;
	font-size:15px;
	font-weight:bold;
	font-style:normal;
	height:80px;
	line-height:40px;
	width:86px;
	text-decoration:none;
	text-align:center;
	text-shadow:1px 1px 0px #454440;
}
button:hover {
	background:-webkit-gradient( linear, left top, left bottom, color-stop(0.05, #544e54), color-stop(1, #000000) );
	background:-moz-linear-gradient( center top, #544e54 5%, #000000 100% );
	filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#544e54', endColorstr='#000000');
	background-color:#544e54;
}
button:active {
	position:relative;
	top:1px;
    height:75px;
}
}

span{
vertical-align: middle;
display: inline-block;
}

#bgbutton{
  vertical-align: middle;
}
              
            
!

JS

              
                var canvas, ctx;
var timerId=250;
var mytime;
var teste=0;

window.addEventListener("load", init);
var b1 = document.getElementById("bouton1");
var b2 = document.getElementById("bouton2");
var b3 = document.getElementById("bouton3");
var tab = new Array(23);

for (var i=0; i<23 ; i++)
{
  tab[i] = new Image();

}
tab[0].src="http://i.imgur.com/NNbFpBn.png";
tab[1].src="http://i.imgur.com/Hh1bSQ9.png";
tab[2].src="http://i.imgur.com/0tmHtJG.png";
tab[3].src="http://i.imgur.com/pzYg8lf.png";
tab[4].src="http://i.imgur.com/pQQFwpm.png";
tab[5].src="http://i.imgur.com/lrMEl2z.png";
tab[6].src="http://i.imgur.com/0crdix9.png";
tab[7].src="http://i.imgur.com/e4k2Q2l.png";
tab[8].src="http://i.imgur.com/pBnsIY3.png";
tab[9].src="http://i.imgur.com/c300uow.png";
tab[10].src="http://i.imgur.com/ViobqKE.png";
tab[11].src="http://i.imgur.com/k1Q8AxG.png";
tab[12].src="http://i.imgur.com/yauEPc4.png";
tab[13].src="http://i.imgur.com/DDt9kEm.png";
tab[14].src="http://i.imgur.com/Z3Eimxm.png";
tab[15].src="http://i.imgur.com/x6EpEin.png";
tab[16].src="http://i.imgur.com/iwL2SX5.png";
tab[17].src="http://i.imgur.com/mJ0geEn.png";
tab[18].src="http://i.imgur.com/tH5y6jd.png";
tab[19].src="http://i.imgur.com/i3E914L.png";
tab[20].src="http://i.imgur.com/lxAPNEz.png";
tab[21].src="http://i.imgur.com/QbHxZF3.png";
tab[22].src="http://i.imgur.com/kpeEfkn.png";

tab.onload=function(){init();};

var imageX = 700, imageY = 80;


var r=Math.floor((Math.random()*23));

function anime()
{
  if(b1.disabled === true)
  {
  ctx.clearRect(0, 0, canvas.width, canvas.height); 
    r=Math.floor((Math.random()*23));
                ctx.drawImage(tab[r], imageX, imageY);
  }
}


function init() {

    //alert("Are you ready to let Mr BUFFA ROCKS ?");
  
  canvas = document.querySelector("#mycanvas");
  ctx = canvas.getContext("2d");
  canvas.style.transition="all 0.3s ease-in-out";
  b1.disabled= false;
  b2.disabled= true;
  b3.disabled= true;
  acdc.currentTime=0; 
  ctx.drawImage(tab[14], imageX, imageY);
  
}



function play(){
  acdc.play();
  document.getElementById("sp").innerHTML="Play";
  b1.disabled= true;
  b2.disabled= false;
  b3.disabled= false;
  mytime = setInterval(anime,timerId);
}

function pause(){
  acdc.pause(); 
  b1.disabled= false;
  b2.disabled= true;
  b3.disabled= false;
  clearInterval(mytime);
}

function stop(){
  acdc.pause(); 
  acdc.currentTime=0;
  b1.disabled= false;
  b2.disabled= true;
  b3.disabled= true;
  clearInterval(mytime);
  ctx.clearRect(0, 0, canvas.width, canvas.height); 
  ctx.drawImage(tab[14], imageX, imageY);
}
              
            
!
999px

Console