apajohnson

Untitled

Aug 7th, 2014
243
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.62 KB | None | 0 0
  1. // ==UserScript==
  2. // @name Cam's Pixel Perfect Rotating Balls
  3. // @namespace http://*.koalabeast.com:*
  4. // @version 1.4.1
  5. // @description Shows ball spin, empty power-up tiles, and pixel perfect tagpro/rolling bomb. Also new textures.
  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. //This is important.
  16. if(tagpro.events.drawPlayer)
  17. return;
  18. //Textures.
  19. var image = new Image();
  20. image.src = "http://i.imgur.com/Iq8cyI2.png";
  21. document.getElementById("tiles").src = "http://i.imgur.com/0KWS9te.png";
  22. document.getElementById("splats").src = "http://lejdesigns.com/splats.png";
  23. document.getElementById("speedpad").src = "http://i.imgur.com/TK7GF6v.png";
  24. document.getElementById("speedpadred").src = "http://i.imgur.com/JG82g3c.png";
  25. document.getElementById("speedpadblue").src = "http://i.imgur.com/0576zNB.png";
  26. document.getElementById("portal").src = "http://i.imgur.com/fxYJYFi.png";
  27. //Empty power-up tile.
  28. tagpro.tiles[6]["x"] = 12;
  29. tagpro.tiles[6]["y"] = 8;
  30.  
  31. tagpro.events.register({
  32. drawPlayer: function(player, context, drawPos, TILESIZE) {
  33. if (player.team == 1)
  34. context.drawImage(image, 3 * 40, 0, 40, 40, drawPos.x, drawPos.y, 40 / tagpro.zoom, 40 / tagpro.zoom);
  35. if (player.team == 2)
  36. context.drawImage(image, 1 * 40, 0, 40, 40, drawPos.x, drawPos.y, 40 / tagpro.zoom, 40 / tagpro.zoom);
  37.  
  38. var radian = (Math.PI / 180),
  39. points = [],
  40. angle = (player.angle/radian % 360)+360;
  41.  
  42. for (i = 0; i < 8; i++) {
  43. var iAngle = angle + 360 / 4 * i,
  44. side = ((iAngle + 270) % 360 > 180) ? 0 : -0,
  45. outerAngle = (iAngle + 90) % 180,
  46. outerAngle = (side > 0) ? 180 - outerAngle : outerAngle,
  47. offset = (-8.546e-10 * Math.pow(outerAngle, 5)
  48. + 4.311e-7 * Math.pow(outerAngle, 4)
  49. - 6.669e-5 * Math.pow(outerAngle, 3)
  50. + 0.001099 * Math.pow(outerAngle, 2)
  51. + 0.3462 * outerAngle),
  52. innerX = 18 * Math.cos(iAngle * radian) / tagpro.zoom,
  53. innerY = 18 * Math.sin(iAngle * radian) / tagpro.zoom,
  54. outerX = 30 * Math.cos((iAngle + offset * side) * radian) / tagpro.zoom,
  55. outerY = 30 * Math.sin((iAngle + offset * side) * radian) / tagpro.zoom;
  56. points.push({ix: innerX, iy: innerY, ox: outerX, oy: outerY});
  57. }
  58.  
  59. for (i = 0; i < points.length; i += 2) {
  60. var color = (player.team == 1) ? 2 : 0;
  61. first = points[i],
  62. second = points[(i + 1) % points.length];
  63. context.save();
  64. context.beginPath();
  65. context.moveTo(drawPos.x + 20 / tagpro.zoom, drawPos.y + 20 / tagpro.zoom);
  66. 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);
  67. context.lineTo(drawPos.x + second.ox + 20 / tagpro.zoom, drawPos.y + second.oy + 20 / tagpro.zoom);
  68. 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);
  69. context.clip();
  70. context.drawImage(image, color * 40, 0, 40, 40 , drawPos.x, drawPos.y, 40 / tagpro.zoom, 40 / tagpro.zoom);
  71. context.restore();
  72. context.closePath();
  73. }
  74.  
  75. if (player.tagpro)
  76. context.drawImage(image, 5 * 40, 0, 40, 40 , drawPos.x, drawPos.y, 40 / tagpro.zoom, 40 / tagpro.zoom);
  77. else
  78. context.drawImage(image, 4 * 40, 0, 40, 40 , drawPos.x, drawPos.y, 40 / tagpro.zoom, 40 / tagpro.zoom);
  79. if (player.bomb && Math.round(Math.random() * 4) == 1) {
  80. context.globalAlpha = 0.7;
  81. context.drawImage(image, 6 * 40, 0, 40, 40 , drawPos.x, drawPos.y, 40 / tagpro.zoom, 40 / tagpro.zoom);
  82. context.globalAlpha = 1;
  83. }
  84. }
  85. });
  86. });
Advertisement
Add Comment
Please, Sign In to add comment