Advertisement
Guest User

Tagpro Semitransparent Spin Balls w/ consistent coloring.

a guest
Jul 7th, 2014
283
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.81 KB | None | 0 0
  1. // ==UserScript==
  2. // @name Tagpro Semitransparent Spin Balls
  3. // @namespace http://*.koalabeast.com:*
  4. // @version 1.4.1
  5. // @description Semitransparent balls with spin and pixel perfect tagpro/rolling bomb.
  6. // @match http://koalabeast.com
  7. // @copyright 2014+, Ly and a little bit of Cumflakes
  8. // @include http://*.koalabeast.com*
  9. // @include http://*.jukejuice.com*
  10. // @include http://*.newcompte.fr*
  11. // @include http://justletme.be*
  12. // ==/UserScript==
  13.  
  14. tagpro.ready(function(){
  15.  
  16. //This is important.
  17. if(tagpro.events.drawPlayer)
  18. return;
  19. var image = new Image();
  20. image.src = "http://i.imgur.com/ugzEjjL.png";
  21.  
  22. tagpro.events.register({
  23. drawPlayer: function(player, context, drawPos, TILESIZE) {
  24.  
  25.  
  26. ///////////added if then statement HERE:
  27. if (tagpro.switchedColors) {
  28. if (player.team == 2)
  29. context.drawImage(image, 3 * 40, 0, 40, 40, drawPos.x, drawPos.y, 40 / tagpro.zoom, 40 / tagpro.zoom);
  30. if (player.team == 1)
  31. context.drawImage(image, 1 * 40, 0, 40, 40, drawPos.x, drawPos.y, 40 / tagpro.zoom, 40 / tagpro.zoom);
  32.  
  33. } else {
  34.  
  35. if (player.team == 1)
  36. context.drawImage(image, 3 * 40, 0, 40, 40, drawPos.x, drawPos.y, 40 / tagpro.zoom, 40 / tagpro.zoom);
  37. if (player.team == 2)
  38. context.drawImage(image, 1 * 40, 0, 40, 40, drawPos.x, drawPos.y, 40 / tagpro.zoom, 40 / tagpro.zoom);
  39. }
  40.  
  41. var radian = (Math.PI / 180),
  42. points = [],
  43. angle = (player.angle/radian % 360)+360;
  44.  
  45. for (i = 0; i < 8; i++) {
  46. var iAngle = angle + 360 / 8 * i,
  47. side = ((iAngle + 270) % 360 > 180) ? 0 : -0,
  48. outerAngle = (iAngle + 90) % 180,
  49. outerAngle = (side > 0) ? 180 - outerAngle : outerAngle,
  50. offset = (-8.546e-10 * Math.pow(outerAngle, 5)
  51. + 4.311e-7 * Math.pow(outerAngle, 4)
  52. - 6.669e-5 * Math.pow(outerAngle, 3)
  53. + 0.001099 * Math.pow(outerAngle, 2)
  54. + 0.3462 * outerAngle),
  55. innerX = 18 * Math.cos(iAngle * radian) / tagpro.zoom,
  56. innerY = 18 * Math.sin(iAngle * radian) / tagpro.zoom,
  57. outerX = 30 * Math.cos((iAngle + offset * side) * radian) / tagpro.zoom,
  58. outerY = 30 * Math.sin((iAngle + offset * side) * radian) / tagpro.zoom;
  59.  
  60. points.push({ix: innerX, iy: innerY, ox: outerX, oy: outerY});
  61. }
  62.  
  63.  
  64. ///////////added if then statement HERE:
  65. for (i = 0; i < points.length; i += 2) {
  66. if (tagpro.switchedColors) {
  67. var color = (player.team == 2) ? 2 : 0;
  68. } else {
  69. var color = (player.team == 1) ? 2 : 0;
  70. }
  71.  
  72.  
  73. first = points[i],
  74. second = points[(i + 1) % points.length];
  75.  
  76. context.save();
  77. context.beginPath();
  78. context.moveTo(drawPos.x + 20 / tagpro.zoom, drawPos.y + 20 / tagpro.zoom);
  79. context.quadraticCurveTo(drawPos.x + first.ix + 20 / tagpro.zoom, drawPos.y + first.iy + 20 / tagpro.zoom, drawPos.x + first.ox + 20 / tagpro.zoom, drawPos.y + first.oy + 20 / tagpro.zoom);
  80. context.lineTo(drawPos.x + second.ox + 20 / tagpro.zoom, drawPos.y + second.oy + 20 / tagpro.zoom);
  81. context.quadraticCurveTo(drawPos.x + second.ix + 20 / tagpro.zoom, drawPos.y + second.iy + 20 / tagpro.zoom, drawPos.x + 20 / tagpro.zoom, drawPos.y + 20 / tagpro.zoom);
  82. context.clip();
  83. context.drawImage(image, color * 40, 0, 40, 40 , drawPos.x, drawPos.y, 40 / tagpro.zoom, 40 / tagpro.zoom);
  84. context.restore();
  85. context.closePath();
  86. }
  87.  
  88. if (player.tagpro)
  89. context.drawImage(image, 5 * 40, 0, 40, 40 , drawPos.x, drawPos.y, 40 / tagpro.zoom, 40 / tagpro.zoom);
  90. else
  91. context.drawImage(image, 4 * 40, 0, 40, 40 , drawPos.x, drawPos.y, 40 / tagpro.zoom, 40 / tagpro.zoom);
  92.  
  93. if (player.bomb && Math.round(Math.random() * 4) == 1) {
  94. context.globalAlpha = 0.7;
  95. context.drawImage(image, 6 * 40, 0, 40, 40 , drawPos.x, drawPos.y, 40 / tagpro.zoom, 40 / tagpro.zoom);
  96. context.globalAlpha = 1;
  97. }
  98. }
  99. });
  100. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement