While making the "Meanwhile, in Gingerbread Land..." project ( https://scratch.mit.edu/projects/456094697/ ), I thought that this candy cane might serve as a simple example of how you can use the sine function to achieve smooth movement in your pen animations. See commented code inside. I've also used named variables instead of constant values, which should give you a good idea of what's happening in the code. All code by me (@kriblo).