140 : Node 140

Balthazar:

xxxx

function draw_score(ctx) { // TODO var x_center = _game.width / 2; var y = 30; var number_width = 80; var padding = 40; draw_number(ctx, _player1.score, x_center - (number_width + padding), y); draw_number(ctx, _player2.score, x_center + padding, y); } // For a 7-segment number, which segments should be drawn to show each number: // Each segment is numbered as follows: // -0- 0000 1 2222 3333 4 4 5555 6666 7777 8888 9999 // 5 1 0 0 1 2 3 4 4 5 6 7 8 8 9 9 // -6- 0 0 1 2222 3333 4444 5555 6666 7 8888 9999 // 4 2 0 0 1 2 3 4 5 6 6 7 8 8 9 // -3- 0000 1 2222 3333 4 5555 6666 7 8888 9999 // For example: // To show a '1', only the 1 and 2 segments are drawn. // To show a '2', the 0, 1, 6, 4 and 3 segments are drawn. var _number_segments = [ [true, true, true, true, true, true, false], // 0 [false, true, true, false, false, false, false], // 1 [true, true, false, true, true, false, true], // 2 [true, true, true, true, false, false, true], // 3 [false, true, true, false, false, true, true], // 4 [true, false, true, true, false, true, true], // 5 [true, false, true, true, true, true, true], // 6 [true, true, true, false, false, false, false], // 7 [true, true, true, true, true, true, true], // 8 [true, true, true, true, false, true, true], // 9 ]; function draw_number(ctx, number, x, y) { // Make sure number is between 0 and 9. if (number < 0) { number = 0; } else if (number > 9) { number = 9; } ctx.fillStyle = "white"; if (_number_segments[number][0]) { ctx.fillRect(x, y, 80, 20); } if (_number_segments[number][1]) { ctx.fillRect(x+60, y, 20, 80); } if (_number_segments[number][2]) { ctx.fillRect(x+60, y+60, 20, 80); } if (_number_segments[number][3]) { ctx.fillRect(x, y+120, 80, 20); } if (_number_segments[number][4]) { ctx.fillRect(x, y+60, 20, 80); } if (_number_segments[number][5]) { ctx.fillRect(x, y, 20, 80); } if (_number_segments[number][6]) { ctx.fillRect(x, y+60, 80, 20); } }

GOTO 150