Skip to content

Instantly share code, notes, and snippets.

@theVDude
Created June 27, 2014 23:36
Show Gist options
  • Save theVDude/035ef0a5d92731b13433 to your computer and use it in GitHub Desktop.
Save theVDude/035ef0a5d92731b13433 to your computer and use it in GitHub Desktop.
show the spin on tagpro balls, as well as make them semitransparent
// ==UserScript==
// @name Tagpro Semitransparent Spin Balls
// @namespace http://*.koalabeast.com:*
// @version 1.4.1
// @description Semitransparent balls with spin and pixel perfect tagpro/rolling bomb.
// @match http://koalabeast.com
// @copyright 2014+, Ly and a little bit of Cumflakes
// @include http://*.koalabeast.com*
// @include http://*.jukejuice.com*
// @include http://*.newcompte.fr*
// @include http://justletme.be*
// ==/UserScript==
tagpro.ready(function(){
//This is important.
if(tagpro.events.drawPlayer)
return;
var image = new Image();
image.src = "http://i.imgur.com/ugzEjjL.png";
tagpro.events.register({
drawPlayer: function(player, context, drawPos, TILESIZE) {
if (player.team == 1)
context.drawImage(image, 3 * 40, 0, 40, 40, drawPos.x, drawPos.y, 40 / tagpro.zoom, 40 / tagpro.zoom);
if (player.team == 2)
context.drawImage(image, 1 * 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 < 8; i++) {
var iAngle = angle + 360 / 8 * i,
side = ((iAngle + 270) % 360 > 180) ? 0 : -0,
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) / 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 + 20 / 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 + 20 / 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 = 0.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