Guest User

Untitled

a guest
Mar 15th, 2015
278
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.90 KB | None | 0 0
  1. // ==UserScript==
  2. // @name TagPro flappy bird Texture
  3. // @description Spin balls and pixel perfect tagpro. Compatible with Tagpro 3.1.0 and greater.
  4. // @version 1.1
  5. // @grant none
  6. // @include http://*.newcompte.fr:*
  7. // @license 2015
  8. // @author CFlakes, SomeBall -1, yank
  9. // @namespace http://www.reddit.com/user/Cumflakes
  10. // ==/UserScript==
  11.  
  12. var textures = [
  13. 'http://i.imgur.com/A1ccKmu.png', // tiles
  14. 'http://i.imgur.com/y1egebV.png', // splats
  15. 'http://i.imgur.com/T4bW2wQ.png', // speedpad
  16. 'http://i.imgur.com/Bf6TidX.png', // speedpadred
  17. 'http://i.imgur.com/B4K1B70.png', // speedpadblue
  18. 'http://i.imgur.com/RLoof3K.png', // portal
  19. 'http://i.imgur.com/yX5h977.png' // tagpro. Not included with most/all texture packs, but you can use your own here.
  20. ]
  21.  
  22. tagpro.loadAssets({
  23. "tiles": textures[0],
  24. "splats": textures[1],
  25. "speedpad": textures[2],
  26. "speedpadRed": textures[3],
  27. "speedpadBlue": textures[4],
  28. "portal": textures[5]
  29. });
  30.  
  31. tagpro.ready(function () {
  32. var textureTagpro = PIXI.Texture.fromImage(textures[6]),
  33. textureBalls = PIXI.Texture.fromImage(textures[0]),
  34. redTexture = new PIXI.Texture(textureBalls, new PIXI.Rectangle(560, 0, 40, 40)),
  35. blueTexture = new PIXI.Texture(textureBalls, new PIXI.Rectangle(600, 0, 40, 40)),
  36. tagproTexture = new PIXI.Texture(textureTagpro, new PIXI.Rectangle(0, 0, 40, 40)),
  37. tr = tagpro.renderer;
  38.  
  39. tr.createBallSprite = function(player) {
  40. var texture = player.team == 1 ? "redball" : "blueball";
  41. player.sprites.actualBall = tagpro.tiles.draw(player.sprites.ball, texture, {x: 0, y: 0}, null, null, 0.01);
  42. player.sprites.actualBall.tileId = texture;
  43. tr.createSpin(player);
  44. };
  45.  
  46. tr.updatePlayerColor = function(player) {
  47. var color = player.team == 1 ? "red" : "blue";
  48. var tileId = color + "ball";
  49. if (player.sprites.actualBall.tileId !== tileId) {
  50. var teamTexture = player.team === 1 ? redTexture : blueTexture;
  51. var baseTexture = tagpro.tiles.getTexture(tileId);
  52. var texture = new PIXI.Texture(baseTexture);
  53. player.sprites.actualBall.setTexture(texture);
  54. player.sprites.actualBall.tileId = tileId;
  55. player.sprites.spin.setTexture(teamTexture);
  56. }
  57. };
  58.  
  59. tr.createSpin = function(player) {
  60. var teamTexture = player.team === 1 ? redTexture : blueTexture;
  61. if (!player.sprites.spin) {
  62. player.sprites.spin = new PIXI.Sprite(teamTexture);
  63. player.sprites.spin.anchor.x = 0.5;
  64. player.sprites.spin.anchor.y = 0.5;
  65. player.sprites.spin.x = 20;
  66. player.sprites.spin.y = 20;
  67. player.sprites.ball.addChild(player.sprites.spin);
  68. }
  69. };
  70.  
  71. var upsp = tagpro.renderer.updatePlayerSpritePosition;
  72. tagpro.renderer.updatePlayerSpritePosition = function(player) {
  73. player.sprites.spin.rotation = player.angle;
  74. upsp(player);
  75. };
  76.  
  77. tr.updateTagpro = function(player) {
  78. if (player.tagpro) {
  79. if (!tr.options.disableParticles && !player.sprites.tagproSparks) {
  80. player.sprites.tagproSparks = new cloudkid.Emitter(
  81. player.sprites.ball,
  82. [tr.particleFireTexture],
  83. tagpro.particleDefinitions.tagproSparks);
  84. tr.emitters.push(player.sprites.tagproSparks);
  85. }
  86. if (player.bomb) {
  87. if (player.sprites.tagproTint) {
  88. player.sprites.ball.removeChild(player.sprites.tagproTint);
  89. player.sprites.tagproTint = null;
  90. }
  91. } else {
  92. if (!player.sprites.tagproTint) {
  93. player.sprites.tagproTint = new PIXI.Graphics();
  94. player.sprites.tagproTint.beginFill(0x00FF00, 0.25).drawCircle(20, 20, 19);
  95. player.sprites.ball.addChild(player.sprites.tagproTint);
  96. }
  97. }
  98. if (!player.sprites.tagproTexture) {
  99. player.sprites.tagproTexture = new PIXI.Sprite(tagproTexture);
  100. player.sprites.ball.addChild(player.sprites.tagproTexture);
  101. player.sprites.tagproTexture.anchor.x = 0.5;
  102. player.sprites.tagproTexture.anchor.y = 0.5;
  103. player.sprites.tagproTexture.x = 20;
  104. player.sprites.tagproTexture.y = 20;
  105. }
  106. player.sprites.tagproTexture.rotation = player.angle;
  107. } else {
  108. if (player.sprites.tagproTint || player.sprites.tagproTexture) {
  109. player.sprites.ball.removeChild(player.sprites.tagproTint);
  110. player.sprites.ball.removeChild(player.sprites.tagproTexture);
  111. player.sprites.tagproTint = null;
  112. player.sprites.tagproTexture = null;
  113. }
  114. if (player.sprites.tagproSparks) {
  115. player.sprites.tagproSparks.emit = false;
  116. var sparksIndex = tr.emitters.indexOf(player.sprites.tagproSparks);
  117. tr.emitters.splice(sparksIndex, 1);
  118. player.sprites.tagproSparks.destroy();
  119. player.sprites.tagproSparks = null;
  120. }
  121. }
  122. };
  123.  
  124. tr.updateRollingBomb = function(player) {
  125. if (player.bomb) {
  126. if (!player.sprites.bomb) {
  127. if (!tr.options.disableParticles) {
  128. player.sprites.rollingBomb = new cloudkid.Emitter(
  129. player.sprites.ball,
  130. [tr.particleTexture],
  131. tagpro.particleDefinitions.rollingBomb);
  132. tr.emitters.push(player.sprites.rollingBomb);
  133. }
  134. var bomb = player.sprites.bomb = new PIXI.Graphics();
  135. bomb.beginFill(0xFFFF00, 0.6).drawCircle(20, 20, 19);
  136. player.sprites.ball.addChild(bomb);
  137. } else {
  138. player.sprites.bomb.alpha = Math.abs(0.6 * Math.sin(performance.now() / 75));
  139. }
  140. } else {
  141. if (player.sprites.bomb) {
  142. player.sprites.ball.removeChild(player.sprites.bomb);
  143. player.sprites.bomb = null;
  144. }
  145. if (player.sprites.rollingBomb) {
  146. if (player.sprites.rollingBomb instanceof cloudkid.Emitter) {
  147. player.sprites.rollingBomb.emit = false;
  148. tr.emitters.splice(tr.emitters.indexOf(player.sprites.rollingBomb), 1);
  149. player.sprites.rollingBomb.destroy();
  150. } else {
  151. player.sprites.rollingBomb.visible = false;
  152. }
  153. player.sprites.rollingBomb = null;
  154. }
  155. }
  156. };
  157. });
Add Comment
Please, Sign In to add comment