To add some life to the game world, we will create a few clouds that will slide in the sky. Their position and animation duration will be random and they will go from the left to the right of the window.
In the world.js file, add the minimum and maximum durations for the cloud animation:
Let's create a method to set the position of the cloud component using the transform CSS property:
methods: { setPosition (left, top) { // Use transform for better performance this.style.transform = `translate(${left}px, ${top}px)` }, }
We need to initialize the horizontal position of the cloud when the image is loaded, so that it's outside of the viewport. Create a new initPosition that uses the setPosition method: