scoreboard.js
1.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
arcs_module(
function (ARCS) {
var ScoreBoard;
ScoreBoard = ARCS.Component.create(
function (score_ids) {
var score = [0,0];
var redScore = document.getElementById(score_ids[0]);
var yellowScore = document.getElementById(score_ids[1]);
//console.log("score_ids", score_id1, score_id2);
var updateScore = function () {
yellowScore.innerHTML = score[0];
redScore.innerHTML = score[1];
};
this.resetScore = function () {
score = [0,0];
updateScore();
};
this.player1IsScoring = function () {
score[0]++;
updateScore();
};
this.player2IsScoring = function () {
score[1]++;
updateScore();
};
this.updateValues = function( a, b) {
score[0] = a;
score[1] = b;
updateScore();
};
},
['resetScore','updateValues', 'player1IsScoring', 'player2IsScoring'],
[]
);
return { ScoreBoard: ScoreBoard };
}
);