MCPcopy Create free account
hub / github.com/codemistic/Web-Development / LetsPlay

Function LetsPlay

Simon Game/index.js:32–64  ·  view source on GitHub ↗
(evt)

Source from the content-addressed store, hash-verified

30}
31
32function LetsPlay(evt){
33
34 //debugger
35 if(level == 0){
36 seq.push(evt.id);
37 count++;
38 clicks++;
39 }
40 else if(evt.id != seq[clicks++]){ //Game Over!!!
41
42 var audio = new Audio("sounds/"+"wrong"+".mp3");
43 audio.play();
44 $("body").addClass("game-over");
45 setTimeout(function(){
46 $("body").removeClass("game-over")
47 },300);
48 $("h1").text( "Game Over, Press Any Key to Restart");
49 document.addEventListener("keyup",function(){
50 startOver();
51 })
52 return;
53 }
54 if(clicks==count){ //Next Level
55 var randval = Math.floor(Math.random()*4); //Generating next color
56 seq.push(colors[randval]);
57 count++;
58 level++;
59 clicks = 0;
60 $("h1").text("LEVEL "+level);
61 for(var i=0;i<seq.length;i++)
62 highlight(i);
63 }
64}
65
66
67

Callers 1

index.jsFile · 0.85

Calls 4

startOverFunction · 0.85
highlightFunction · 0.85
$Function · 0.50
textMethod · 0.45

Tested by

no test coverage detected