Feel free to use this in your own project!
[NOTE:] The code bugs out when you start it at an X position that is not 0. (I have no idea how to fix it, sadly.)