Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Court: {
- initialize: function(pong) {
- var w = pong.width;
- var h = pong.height;
- var ww = pong.cfg.wallWidth;
- this.ww = ww;
- this.walls = [];
- this.walls.push({x: 0, y: 0, width: w, height: ww});
- this.walls.push({x: 0, y: h - ww, width: w, height: ww});
- var nMax = (h / (ww*2));
- for(var n = 0 ; n < nMax ; n++) { // draw dashed halfway line
- this.walls.push({x: (w / 2) - (ww / 2),
- y: (ww / 2) + (ww * 2 * n),
- width: ww, height: ww});
- }
- var sw = 3*ww;
- var sh = 4*ww;
- this.score1 = {x: 0.5 + (w/2) - 1.5*ww - sw, y: 2*ww, w: sw, h: sh};
- this.score2 = {x: 0.5 + (w/2) + 1.5*ww, y: 2*ww, w: sw, h: sh};
- },
- draw: function(ctx, scorePlayer1, scorePlayer2) {
- ctx.fillStyle = Pong.Colors.walls;
- for(var n = 0 ; n < this.walls.length ; n++)
- ctx.fillRect(this.walls[n].x, this.walls[n].y, this.walls[n].width, this.walls[n].height);
- this.drawDigit(ctx, scorePlayer1, this.score1.x, this.score1.y, this.score1.w, this.score1.h);
- this.drawDigit(ctx, scorePlayer2, this.score2.x, this.score2.y, this.score2.w, this.score2.h);
- },
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement