Jump to content

Physics cursor: Difference between revisions

Guest-1052 (talk | contribs)
Created page with "<p> Physics cursor script by fp, used for most physics parkour worlds. Often edited and also mixed with the improved Guest cursors script, Also often mixed with a ratelimit of 0 chars per second: keyConfig.cursorUp = ""; keyConfig.cursorDown = ""; keyConfig.cursorLeft = ""; keyConfig.cursorRight = ""; var backpressureX = 0; var backpressureY = 0; var velocityX = 0; var velocityY = 0; var keyLeft = false; var keyRight = false; var keyUp = false; document.addEventList..."
 
Dat Hack3r (talk | contribs)
m Removed incorrectly placed semicolon and added new lines for readability.
 
(7 intermediate revisions by 3 users not shown)
Line 1: Line 1:
<p>
/* Physics cursor script by fp, used for most physics parkour worlds. Often combined with the improved Guest cursors script and used with a ratelimit of 0 chars per second. */
/* Physics cursor script by fp, used for most physics parkour worlds. Often edited and also mixed with the improved Guest cursors script, Also often mixed with a ratelimit of 0 chars per second */
keyConfig.cursorUp = "";
keyConfig.cursorUp = "";
keyConfig.cursorDown = "";
keyConfig.cursorDown = "";
Line 12: Line 11:
var keyRight = false;
var keyRight = false;
var keyUp = false;
var keyUp = false;
document.addEventListener("keydown", function(e) {
document.addEventListener("keydown", function(e) {
     if(checkKeyPress(e, "UP")) {
     if (checkKeyPress(e, "UP")) {
         keyUp = true;
         keyUp = true;
     }
     }
     if(checkKeyPress(e, "LEFT")) {
     if (checkKeyPress(e, "LEFT")) {
         keyLeft = true;
         keyLeft = true;
     }
     }
     if(checkKeyPress(e, "RIGHT")) {
     if (checkKeyPress(e, "RIGHT")) {
         keyRight = true;
         keyRight = true;
     }
     }
});
});
document.addEventListener("keyup", function(e) {
document.addEventListener("keyup", function(e) {
     if(checkKeyPress(e, "UP")) {
     if (checkKeyPress(e, "UP")) {
         keyUp = false;
         keyUp = false;
     }
     }
     if(checkKeyPress(e, "LEFT")) {
     if (checkKeyPress(e, "LEFT")) {
         keyLeft = false;
         keyLeft = false;
     }
     }
     if(checkKeyPress(e, "RIGHT")) {
     if (checkKeyPress(e, "RIGHT")) {
         keyRight = false;
         keyRight = false;
     }
     }
});
});
function tick() {
function tick() {
     backpressureY += velocityY + 0.7;
     backpressureY += velocityY + 0.7;
Line 39: Line 40:
     backpressureX += velocityX;
     backpressureX += velocityX;
     velocityX /= 1.2;
     velocityX /= 1.2;
     if(keyLeft) velocityX -= 2;
     if (keyLeft) velocityX -= 2;
     if(keyRight) velocityX += 2;
     if (keyRight) velocityX += 2;
     if(keyUp) {
     if (keyUp) {
         moveCursor("down");
         moveCursor("down");
         var char = getChar();
         var char = getChar();
         moveCursor("up");
         moveCursor("up");
         if(char != " ") {
         if (char != " ") {
             velocityY -= 3;
             velocityY -= 3;
         }
         }
     }
     }
     if(!keyLeft && !keyRight && Math.abs(velocityX) > 0.5) velocityX = 0;
     if (!keyLeft && !keyRight && Math.abs(velocityX) > 0.5) velocityX = 0;
 
     if (backpressureY >= 1) {
     if(backpressureY >= 1) {
         backpressureY %= 1;
         backpressureY %= 1;
         moveCursor("down");
         moveCursor("down");
         if(getChar() != " ") {
         if (getChar() != " ") {
             moveCursor("up");
             moveCursor("up");
             velocityY = 0;
             velocityY = 0;
         }
         }
     } else if(backpressureY <= -1) {
     } else if (backpressureY <= -1) {
         backpressureY %= 1;
         backpressureY %= 1;
         moveCursor("up");
         moveCursor("up");
         if(getChar() != " ") {
         if (getChar() != " ") {
             moveCursor("down");
             moveCursor("down");
             velocityY = 0;
             velocityY = 0;
         }
         }
     }
     }
     if(backpressureX >= 1) {
     if (backpressureX >= 1) {
         backpressureX %= 1;
         backpressureX %= 1;
         moveCursor("right");
         moveCursor("right");
         if(getChar() != " ") {
         if (getChar() != " ") {
             velocityX = 0;
             velocityX = 0;
             moveCursor("left");
             moveCursor("left");
         }
         }
     } else if(backpressureX <= -1) {
     } else if (backpressureX <= -1) {
         backpressureX %= 1;
         backpressureX %= 1;
         moveCursor("left");
         moveCursor("left");
         if(getChar() != " ") {
         if (getChar() != " ") {
             velocityX = 0;
             velocityX = 0;
             moveCursor("right");
             moveCursor("right");
Line 82: Line 82:
     }
     }
}
}
setInterval(tick, 1000 / 30);
setInterval(tick, 1000 / 30);
</p>
 
[[Category:Scripts]]
 
/* [[Category:Scripts]] */