Skip to content

Instantly share code, notes, and snippets.

@theVDude
Last active August 29, 2015 14:02
Show Gist options
  • Save theVDude/ae7a3361cc10b0d584ec to your computer and use it in GitHub Desktop.
Save theVDude/ae7a3361cc10b0d584ec to your computer and use it in GitHub Desktop.
rotate ball images from texture pack in tagpro
// ==UserScript==
// @name Tagpro Rotating Balls - NewCompte's server
// @namespace http://www.reddit.com/user/NewCompte
// @description Tagpro Rotating Balls
// @include http://*.koalabeast.com:*
// @license GPL
// @author NewCompte
// @version 0.5
// ==/UserScript==
function myRotatingBallsScript() {
tagpro.ready(function(){
//This is important.
if(tagpro.events.drawPlayer)
return;
tagpro.events.register({
drawPlayer: function(player, context, drawPos, TILESIZE) {
context.save();
context.translate(drawPos.x + (TILESIZE / 2) * (1 / tagpro.zoom), drawPos.y + (TILESIZE / 2) * (1 / tagpro.zoom));
context.rotate(player.angle)
context.translate(-drawPos.x - (TILESIZE / 2) * (1 / tagpro.zoom), -drawPos.y - (TILESIZE / 2) * (1 / tagpro.zoom));
tagpro.tiles.drawWithZoom(context, player.team == 1 ? "redball" : "blueball", drawPos);
if (player.bomb && Math.round(Math.random() * 4) == 1) {
context.fillStyle = "rgba(255, 255, 0, .50)";
context.beginPath();
context.arc(drawPos.x + (TILESIZE / 2) * (1 / tagpro.zoom), drawPos.y + (TILESIZE / 2) * (1 / tagpro.zoom), 20 * (1 / tagpro.zoom), 0, Math.PI*2, true);
context.closePath();
context.fill();
};
if (player.tagpro) {
context.strokeStyle = "#00FF00";
context.fillStyle = "rgba(0, 255, 0, .25)";
context.lineWidth = 3 * (1 / tagpro.zoom);
context.beginPath();
context.arc(drawPos.x + (TILESIZE / 2) * (1 / tagpro.zoom), drawPos.y + (TILESIZE / 2) * (1 / tagpro.zoom), 20 * (1 / tagpro.zoom), 0, Math.PI*2, true);
context.closePath();
if (!player.bomb)
context.fill();
context.stroke();
}
context.restore();
}
});
});
}
var source = "("+ myRotatingBallsScript + ")()";
var script = document.createElement('script');
script.setAttribute("type", "application/javascript");
script.textContent = source;
document.body.appendChild(script);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment