Skip to content

Instantly share code, notes, and snippets.

@EliTheCoder
Created December 25, 2016 01:40
Show Gist options
  • Save EliTheCoder/98b261ff9f1bbc8f847f75d0475d0522 to your computer and use it in GitHub Desktop.
Save EliTheCoder/98b261ff9f1bbc8f847f75d0475d0522 to your computer and use it in GitHub Desktop.
javascript:(function () { var refreshRate = 100; var particleLimit = 15; var snake = { x: (window.innerWidth * Math.random()) - window.pageXOffset, y: (window.innerHeight * Math.random()) - window.pageYOffset, dx: Math.ceil(Math.random() * 30) - 15, dy: Math.ceil(Math.random() * 30) - 15, atan2: Math.atan2(this.dx, this.dy) + (Math.PI / 2), body: [], update: function () { // IIC.setAngle(Math.ceil(Math.random() * 360) * Math.PI / 180); if (this.x < 0) { this.x = 0; this.dx = -this.dx; } else if (this.x > window.innerWidth) { this.x = window.innerWidth; this.dx = -this.dx; } if (this.y < 0) { this.y = 0; this.dy = -this.dy; } else if (this.y > window.innerHeight) { this.y = window.innerHeight; this.dy = -this.dy; } var ddx = (this.dx + ((Math.random() * 10) - 5)); var ddy = (this.dy + ((Math.random() * 10) - 5)); this.x = this.x + ddx; this.y = this.y + ddy; this.atan2 = Math.atan2(ddy, ddx) + (Math.PI / 2); this.body.unshift({ x: this.x, y: this.y, atan2: this.atan2 }); if (this.body.length > particleLimit) { this.body.pop(); } for (var i = this.body.length - 1; i >= 0; --i) { IIC.setAngle(this.body[i].atan2); mouseClick({ clientX: this.body[i].x - window.pageXOffset, clientY: this.body[i].y - window.pageYOffset, button: 0 }); } } } setInterval(function () { snake.update(); }, refreshRate);})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment