Advertisement
Guest User

Untitled

a guest
Sep 23rd, 2017
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.97 KB | None | 0 0
  1. function drawBalls(positions) {
  2. // draw 'me'
  3. let me = replay_data.me;
  4. let player = positions[me];
  5. // what team?
  6. let team = Array.isArray(player.team) ? player.team[frame]
  7. : player.team;
  8. let center_x = context.canvas.width / 2;
  9. let center_y = context.canvas.height / 2;
  10. let player_x = center_x - TILE_SIZE / 2;
  11. let player_y = center_y - TILE_SIZE / 2;
  12. if (!player.dead[frame]) {
  13. // draw own ball with or without spin
  14. if (!options.spin || typeof player.angle === 'undefined') {
  15. context.drawImage(textures.tiles,
  16. 13 * TILE_SIZE, (team == 1 ? 7 : 8) * TILE_SIZE,
  17. TILE_SIZE, TILE_SIZE,
  18. player_x, player_y,
  19. TILE_SIZE, TILE_SIZE);
  20. } else {
  21. context.translate(center_x, center_y);
  22. context.rotate(player.angle[frame]);
  23. context.drawImage(textures.tiles,
  24. 13 * TILE_SIZE, (team == 1 ? 7 : 8) * TILE_SIZE,
  25. TILE_SIZE, TILE_SIZE,
  26. -20, -20,
  27. TILE_SIZE,
  28. TILE_SIZE);
  29. context.rotate(-player.angle[frame]);
  30. context.translate(-center_x, -center_y);
  31. }
  32.  
  33. drawPowerups(me, player_x, player_y, positions);
  34. drawFlag(me, player_x, player_y, positions);
  35. let name = Array.isArray(player.name) ? player.name[frame]
  36. : player.name;
  37. drawName(name, player.auth[frame], player_x, player_y);
  38. drawDegree(player.degree[frame], player_x, player_y);
  39. if (player.flair) {
  40. drawFlair(player.flair[frame], player_x, player_y);
  41. }
  42. }
  43. ballPop(positions, me)
  44. rollingBombPop(positions, me)
  45.  
  46. // draw other balls
  47. for (let j in positions) {
  48. if (!j.startsWith('player')) continue;
  49. if (j == me) continue;
  50. let player = positions[j];
  51. let x = player.x[frame] - positions[me].x[frame] + context.canvas.width / 2 - TILE_SIZE / 2;
  52. let y = player.y[frame] - positions[me].y[frame] + context.canvas.height / 2 - TILE_SIZE / 2;
  53. if (!player.dead[frame] && player.draw[frame]) {
  54. if (frame == 0 || player.draw[frame - 1] == true) {
  55. if ((player.dead[frame - 1] &&
  56. player.x[frame] != player.x[frame - replay_data.fps]) ||
  57. !player.dead[frame - 1]) {
  58. let team = Array.isArray(player.team) ? player.team[frame]
  59. : player.team;
  60.  
  61. // draw with or without spin
  62. if (!options.spin || typeof player.angle === 'undefined') {
  63. context.drawImage(textures.tiles,
  64. (team == 1 ? 14 : 15) * TILE_SIZE, 0,
  65. TILE_SIZE, TILE_SIZE,
  66. x, y,
  67. TILE_SIZE, TILE_SIZE);
  68. } else {
  69. context.translate(
  70. player.x[frame] - positions[me].x[frame] + context.canvas.width / 2,
  71. player.y[frame] - positions[me].y[frame] + context.canvas.height / 2);
  72. context.rotate(player.angle[frame]);
  73. context.drawImage(textures.tiles,
  74. (team == 1 ? 14 : 15) * TILE_SIZE, 0,
  75. TILE_SIZE, TILE_SIZE,
  76. -TILE_SIZE / 2, -TILE_SIZE / 2,
  77. TILE_SIZE, TILE_SIZE);
  78. context.rotate(-player.angle[frame]);
  79. context.translate(
  80. -(player.x[frame] - positions[me].x[frame] + context.canvas.width / 2),
  81. -(player.y[frame] - positions[me].y[frame] + context.canvas.height / 2));
  82. }
  83.  
  84. drawPowerups(j, x, y, positions);
  85. drawFlag(j, x, y, positions);
  86. let name = Array.isArray(player.name) ? player.name[frame]
  87. : player.name;
  88.  
  89. drawName(name, player.auth[frame], x, y);
  90. drawDegree(player.degree[frame], x, y);
  91. if (typeof player.flair !== 'undefined') {
  92. drawFlair(player.flair[frame], x, y);
  93. }
  94. rollingBombPop(positions, j);
  95. }
  96. }
  97. }
  98. ballPop(positions, j);
  99. }
  100. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement