Advertisement
causevd

Dashed line

May 19th, 2013
6,860
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.22 KB | None | 0 0
  1. Court: {
  2.  
  3. initialize: function(pong) {
  4. var w = pong.width;
  5. var h = pong.height;
  6. var ww = pong.cfg.wallWidth;
  7.  
  8. this.ww = ww;
  9. this.walls = [];
  10. this.walls.push({x: 0, y: 0, width: w, height: ww});
  11. this.walls.push({x: 0, y: h - ww, width: w, height: ww});
  12. var nMax = (h / (ww*2));
  13. for(var n = 0 ; n < nMax ; n++) { // draw dashed halfway line
  14. this.walls.push({x: (w / 2) - (ww / 2),
  15. y: (ww / 2) + (ww * 2 * n),
  16. width: ww, height: ww});
  17. }
  18.  
  19. var sw = 3*ww;
  20. var sh = 4*ww;
  21. this.score1 = {x: 0.5 + (w/2) - 1.5*ww - sw, y: 2*ww, w: sw, h: sh};
  22. this.score2 = {x: 0.5 + (w/2) + 1.5*ww, y: 2*ww, w: sw, h: sh};
  23. },
  24.  
  25. draw: function(ctx, scorePlayer1, scorePlayer2) {
  26. ctx.fillStyle = Pong.Colors.walls;
  27. for(var n = 0 ; n < this.walls.length ; n++)
  28. ctx.fillRect(this.walls[n].x, this.walls[n].y, this.walls[n].width, this.walls[n].height);
  29. this.drawDigit(ctx, scorePlayer1, this.score1.x, this.score1.y, this.score1.w, this.score1.h);
  30. this.drawDigit(ctx, scorePlayer2, this.score2.x, this.score2.y, this.score2.w, this.score2.h);
  31. },
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement