Skip to content

Instantly share code, notes, and snippets.

@powerc9000
Created July 16, 2012 21:59
Show Gist options
  • Save powerc9000/3125350 to your computer and use it in GitHub Desktop.
Save powerc9000/3125350 to your computer and use it in GitHub Desktop.
some vector stuff for peter
degrees = angle * (180/Math.PI);
slope = tangent(degrees);
length = Math.sqrt(1*1,m*m);
vector = [1/length,m/length];
next_point = function(distance,start,magnatude){
var end = []
magnatude[0] = magnatude[0]*distance;
magnatude[1] = magnatude[1]*distance;
end[0] = start[0] + magnatude[0];
end[1] = start[1] + magnatude[1];
return end;
}
next = next_point(ship.speed*modifier,[ship.x,ship.y],vector);
ship.x = next[0];
ship.y = next[1];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment