Created
September 30, 2014 22:15
-
-
Save theVDude/fbf0aacd801adfdc78d7 to your computer and use it in GitHub Desktop.
Tagpro BeachBalls!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // ==UserScript== | |
| // @name Tagpro-Beach-Balls | |
| // @namespace http://*.koalabeast.com:* | |
| // @version 1.4 | |
| // @description Fun at the beach! | |
| // @match http://koalabeast.com | |
| // @copyright 2014+, Ly | |
| // @include http://*.koalabeast.com:* | |
| // ==/UserScript== | |
| tagpro.ready(function(){ | |
| //This is important. | |
| if(tagpro.events.drawPlayer) | |
| return; | |
| var image = new Image(); | |
| image.src = "http://i.imgur.com/91Q6srF.png"; | |
| tagpro.events.register({ | |
| drawPlayer: function(player, context, drawPos, TILESIZE) { | |
| context.drawImage(image, 3 * 40, 0, 40, 40, drawPos.x, drawPos.y, 40 / tagpro.zoom, 40 / tagpro.zoom); | |
| var radian = (Math.PI / 180), | |
| points = [], | |
| angle = (player.angle/radian % 360)+360; | |
| for (i = 0; i < 6; i++) { | |
| var iAngle = angle + 360 / 6 * i, | |
| side = ((iAngle + 270) % 360 > 180) ? 1 : -1, | |
| outerAngle = (iAngle + 90) % 180, | |
| outerAngle = (side > 0) ? 180 - outerAngle : outerAngle, | |
| offset = (-8.546e-10 * Math.pow(outerAngle, 5) | |
| + 4.311e-7 * Math.pow(outerAngle, 4) | |
| - 6.669e-5 * Math.pow(outerAngle, 3) | |
| + 0.001099 * Math.pow(outerAngle, 2) | |
| + 0.3462 * outerAngle), | |
| innerX = 18 * Math.cos(iAngle * radian) / tagpro.zoom, | |
| innerY = (18 * Math.sin(iAngle * radian) - 10) / tagpro.zoom, | |
| outerX = 30 * Math.cos((iAngle + offset * side) * radian) / tagpro.zoom, | |
| outerY = 30 * Math.sin((iAngle + offset * side) * radian) / tagpro.zoom; | |
| points.push({ix: innerX, iy: innerY, ox: outerX, oy: outerY}); | |
| } | |
| for (i = 0; i < points.length; i += 2) { | |
| var color = (player.team == 1) ? 2 : 0; | |
| first = points[i], | |
| second = points[(i + 1) % points.length]; | |
| context.save(); | |
| context.beginPath(); | |
| context.moveTo(drawPos.x + 20 / tagpro.zoom, drawPos.y + 10 / tagpro.zoom); | |
| 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); | |
| context.lineTo(drawPos.x + second.ox + 20 / tagpro.zoom, drawPos.y + second.oy + 20 / tagpro.zoom); | |
| context.quadraticCurveTo(drawPos.x + second.ix + 20 / tagpro.zoom, drawPos.y + second.iy + 20 / tagpro.zoom, drawPos.x + 20 / tagpro.zoom, drawPos.y + 10 / tagpro.zoom); | |
| context.clip(); | |
| context.drawImage(image, color * 40, 0, 40, 40 , drawPos.x, drawPos.y, 40 / tagpro.zoom, 40 / tagpro.zoom); | |
| context.restore(); | |
| context.closePath(); | |
| } | |
| if (player.tagpro) | |
| context.drawImage(image, 5 * 40, 0, 40, 40 , drawPos.x, drawPos.y, 40 / tagpro.zoom, 40 / tagpro.zoom); | |
| else | |
| context.drawImage(image, 4 * 40, 0, 40, 40 , drawPos.x, drawPos.y, 40 / tagpro.zoom, 40 / tagpro.zoom); | |
| if (player.bomb && Math.round(Math.random() * 4) == 1) { | |
| context.globalAlpha = .7; | |
| context.drawImage(image, 6 * 40, 0, 40, 40 , drawPos.x, drawPos.y, 40 / tagpro.zoom, 40 / tagpro.zoom); | |
| context.globalAlpha = 1; | |
| } | |
| } | |
| }); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment