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

Function start

Memory-Matching-Game/gameScript.js:29–74  ·  view source on GitHub ↗
(r,l)

Source from the content-addressed store, hash-verified

27
28//Starting the game
29function start(r,l) {
30 //Timer and moves
31 min=0, sec=0, moves=0;
32 $("#time").html("Time: 00:00");
33 $("#moves").html("Moves: 0");
34 time = setInterval(function() {
35 sec++;
36 if(sec==60) {
37 min++; sec=0;
38 }
39 if(sec<10)
40 $("#time").html("Time: 0"+min+":0"+sec);
41 else
42 $("#time").html("Time: 0"+min+":"+sec);
43 }, 1000);
44 rem=r*l/2, noItems=rem;
45 mode = r+"x"+l;
46 //Generating item array and shuffling it
47 var items = [];
48 for (var i=0;i<noItems;i++)
49 items.push(em[i]);
50 for (var i=0;i<noItems;i++)
51 items.push(em[i]);
52 var tmp, c, p = items.length;
53 if(p) while(--p) {
54 c = Math.floor(Math.random() * (p + 1));
55 tmp = items[c];
56 items[c] = items[p];
57 items[p] = tmp;
58 }
59
60 //Creating table
61 $("table").html("");
62 var n=1;
63 for (var i = 1;i<=r;i++) {
64 $("table").append("<tr>");
65 for (var j = 1;j<=l;j++) {
66 $("table").append(`<td id='${n}' onclick="change(${n})"><div class='inner'><div class='front'></div><div class='back'><p>${items[n-1]}</p></div></div></td>`);
67 n++;
68 }
69 $("table").append("</tr>");
70 }
71
72 //Hiding instructions screen
73 $("#ol").fadeOut(500);
74}
75
76//Function for flipping blocks
77function change(x) {

Callers

nothing calls this directly

Calls 2

$Function · 0.50
appendMethod · 0.45

Tested by

no test coverage detected