
previous

page 24
next
my new cell_clicked.js
function cell_clicked(image) {
image.src='counters/' + pick + '.png';
image.setAttribute('cn',pick);
var id=image.id;
var row=parseInt(id/5);
var arr=get_cns(row);
var score=worth(arr);
var element=document.getElementById('s' + row);
element.textContent=score;
pick=Random(9);
}
image.src='counters/' + pick + '.png';
image.setAttribute('cn',pick);
var id=image.id;
var row=parseInt(id/5);
var arr=get_cns(row);
var score=worth(arr);
var element=document.getElementById('s' + row);
element.textContent=score;
pick=Random(9);
}
my new get_cns.js
function get_cns(row) {
var arr=[];
var id=row * 5;
for (var i=0; i<5; i++) {
var element=document.getElementById(id);
var cn=element.getAttribute('cn');
id++;
arr[i]=cn;
}
return arr;
}
var arr=[];
var id=row * 5;
for (var i=0; i<5; i++) {
var element=document.getElementById(id);
var cn=element.getAttribute('cn');
id++;
arr[i]=cn;
}
return arr;
}
You should now have a playable game with two rows.
Modify index.html so that you have the planned five rows.
When you have finished playing, concentrate on what still needs to be done.
previous
next