MarkoPaste

BallOnString MPP

Dec 13th, 2018
445
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==UserScript==
  2. // @name         BallOnString.js
  3. // @namespace    http://meowbin.com/BallOnString.js
  4. // @version      1
  5. // @description  Turn MPP cursor into Ball on String
  6. // @author       electrashave
  7. // @match        http://www.multiplayerpiano.com/*
  8. // @match        http://mpp-evolution.com/*
  9. // @match        http://cursors.me/piano/*
  10. // @grant        none
  11. // ==/UserScript==
  12. var mass = 100;
  13. var gravity = 5;
  14. var friction = 4;
  15. var pos = {x: 50, y: 50};
  16. var pos2 = {x: 50, y: 50};
  17. var acc = {x: 0, y: 0};
  18. var vel = {x: 0, y: 0};
  19. var follower = "7504f8a8bb9e7c39ddbcbd27";
  20. var followPos = {x: 50, y: 50};
  21. MPP.client.on("m", function(msg) {
  22.     var part = MPP.client.findParticipantById(msg.id);
  23.     if (part._id == MPP.client.user._id) return;
  24.     followPos.x = +msg.x;
  25.     followPos.y = +msg.y;
  26. });
  27. var updateInt = setInterval(function() {
  28.     pos2.x = followPos.x;
  29.     pos2.y = followPos.y;
  30.     acc.x = ((pos2.x-pos.x) - (friction*vel.x))/mass;
  31.     acc.y = ((pos2.y-pos.y) - (friction*vel.y) + gravity)/mass;
  32.     vel.x += acc.x;
  33.     vel.y += acc.y;
  34.     pos.x += vel.x;
  35.     pos.y += vel.y;
  36.     MPP.client.sendArray([{m: "m", x: MPP.client.getOwnParticipant().x = pos.x, y: MPP.client.getOwnParticipant().y = pos.y}]);
  37. }, 15);
Advertisement
Add Comment
Please, Sign In to add comment