This is the project that used to demonstrate moving objects within a boundary.
In my Mern stack class we had an assignemnt to make PacMan move within the boundaries of the web page. Some of the code in the starter file was provided, but not all. This was my way of keeping PacMan in the window
I couldn't really have PacMan running back and forth without the waka waka sound, so I found a free wav file and made it happen. Depending on how you alter the timeout will depend on how in sync it is. I think it's best around 200.