A to move left, D to move right. Catch the sword once to win. Spawn is usually random.
I don't know... I keep changing the code so it actually works but I have no idea...