I have come across a stunning 2D Highway background image that I plan to use for my mobile racing game project which involves JS and CSS3. The image can be found at this link.
My goal is to create an animation of the road in order to give players the illusion of movement. However, I am currently facing issues with the smoothness of the animation, particularly when viewed on mobile browsers.
Could anyone provide me with some guidance on the best practices for handling this type of scenario?
The current approach I am using involves the following code snippet:
.main {
background-image: url(https://opengameart.org/sites/default/files/background-1_0.png);
background-repeat-x: no-repeat;
background-size: 103%;
background-repeat-y: repeat;
background-position-y: 27px;
animation: loopingRoad 0.1s infinite;
height: 100%;
width: 100%;
}
@keyframes loopingRoad {
100% {
background-position-y: 1000%;
}
0% {
background-position-y: 0%
}
}