Skip to content

Instantly share code, notes, and snippets.

@akilism
Created April 16, 2015 02:42
Show Gist options
  • Save akilism/b7bcc957a175c5d1b725 to your computer and use it in GitHub Desktop.
Save akilism/b7bcc957a175c5d1b725 to your computer and use it in GitHub Desktop.
lua vectors for pico8
--begin vector functions
function addv(v1, v2)
return {x=v1.x+v2.x, y=v1.y+v2.y}
end
function subv(v1,v2)
return {x=v1.x-v2.x, y=v1.y-v2.y}
end
function multv(v,n)
return {x=v.x*n, y=v.y*n}
end
function divv(v, n)
return {x=v.x/n, y=v.y/n}
end
function magsqrv(v)
return (v.x*v.x)+(v.y*v.y)
end
function distsqrv(v1, v2)
return (v1.x-v2.x) * (v1.x-v2.x) + (v1.y-v2.y) * (v1.y-v2.y)
end
--end vector functions
@davidalbertainley
Copy link

thanks buddy!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment