Advertisement
Guest User

Untitled

a guest
Sep 23rd, 2017
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.13 KB | None | 0 0
  1. function drawBalls(positions) {
  2. let players = replay_data.players;
  3. // draw other balls
  4. for (let id of players) {
  5. let player = positions[id];
  6. let {x, y} = worldToScreen(player.x[frame], player.y[frame]);
  7. if (!player.dead[frame] && player.draw[frame]) {
  8. let team = Array.isArray(player.team) ? player.team[frame]
  9. : player.team;
  10.  
  11. if (('name' in player)=="mP") {
  12. context.drawImage(textures.tiles,
  13. (team == 1 ? 14 : 15) * TILE_SIZE, 0,
  14. TILE_SIZE, TILE_SIZE,
  15. x, y,
  16. TILE_SIZE, TILE_SIZE);
  17. } else if (('name' in player)=="Green") {
  18. // Move context to be centered on player before rotating.
  19. context.translate(
  20. x + TILE_SIZE / 2, y + TILE_SIZE / 2);
  21. context.rotate(player.angle[frame]);
  22. context.drawImage(textures.tiles,
  23. 13 * TILE_SIZE, (team == 1 ? 7 : 8) * TILE_SIZE,
  24. TILE_SIZE, TILE_SIZE,
  25. -TILE_SIZE / 2, -TILE_SIZE / 2,
  26. TILE_SIZE, TILE_SIZE);
  27. context.rotate(-player.angle[frame]);
  28. context.translate(
  29. -(x + TILE_SIZE / 2), -(y + TILE_SIZE / 2));
  30. } else {
  31. // Move context to be centered on player before rotating.
  32. context.translate(
  33. x + TILE_SIZE / 2, y + TILE_SIZE / 2);
  34. context.rotate(player.angle[frame]);
  35. context.drawImage(textures.tiles,
  36. (team == 1 ? 14 : 15) * TILE_SIZE, 0,
  37. TILE_SIZE, TILE_SIZE,
  38. -TILE_SIZE / 2, -TILE_SIZE / 2,
  39. TILE_SIZE, TILE_SIZE);
  40. context.rotate(-player.angle[frame]);
  41. context.translate(
  42. -(x + TILE_SIZE / 2), -(y + TILE_SIZE / 2));
  43. }
  44.  
  45.  
  46.  
  47. drawPowerups(id, x, y, positions);
  48. drawFlag(id, x, y, positions);
  49. let name = Array.isArray(player.name) ? player.name[frame]
  50. : player.name;
  51. drawName(name, player.auth[frame], x, y);
  52. drawDegree(player.degree[frame], x, y);
  53. drawFlair(player.flair[frame], x, y);
  54. }
  55. ballPop(positions, id);
  56. rollingBombPop(positions, id);
  57. }
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement