https://scratch.mit.edu/projects/884450378/

Might be a bit complicated but I suggest you look though the code.