previous

page 16

next

All that remains is to stop the game after 10 goes - something like this:

function remove_move(el) {
el.classList.remove('move');
if (g_n<10) Show('buttons');
}
function button_click(colr) {
Hide('buttons');
g_n++;
if (g_cards[1]==g_cards[4]) {
if (colr=='green') g_score++;
} else {
if (colr=='red') g_score++;
}
show_card(1);
show_card(4);
if (g_n==10) {
finale();
} else {
// wait two seconds
setTimeout(button_click2,2000);
}
}
...

For the finale I propose we just report on the score so we'll need a div for that - let's give it an id of finale and move it up so that it replaces the buttons.

previous
next