How can I smoothly rotate my puzzle?

Why does it have to be in a function?