Here’s how:
I saw a lot of people asking about this, or at least enough that got me thinking I should try and implement it for my own game ideas. Now we can just link people to this thread when they ask
Feel free to ask any questions.
I tried my best to add lots of comments in the code.