Skip to content

Instantly share code, notes, and snippets.

@acceptable-security
Created May 22, 2014 19:57
Show Gist options
  • Save acceptable-security/c98851b51148061b6364 to your computer and use it in GitHub Desktop.
Save acceptable-security/c98851b51148061b6364 to your computer and use it in GitHub Desktop.
function Player::ropeTick(%player) {
if(isObject(%player.currentRope)) {
%point = %player.currentRope.hook.getPosition();
%player_next_tick = vectorAdd(%player.getPosition(),%player.getVelocity());
%player_distance_next_tick = vectorDist(%player_next_tick, %point);
if(%player_distance_next_tick > %player.currentRope.length) {
%velocity = %player.getVelocity();
%velocity = vectorNormalize(%velocity);
%velocity = vectorMultiply(%velocity, vectorSub(%point, %player.getPosition()));
%player.setVelocity(%velocity);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment