0

In a 2d platformer game coded with js, what code can i use to move the background to the opposite direction of the ball?

A platformer game (javascript-based) will allow a ball (player) to move the specified direction while keeping the background static. Which means the ball leaves the visible screen part as it keeps moving. What code can be written to all the background move the opposite direction to the ball so that the ball appears to be still but moving parallel to the background.

4th Dec 2021, 7:41 PM
Coder Doing Coder Stuff
1 Resposta
0
In most platformer game, the background is generally kept static with no user controls. it is only the character and the camera moving. to make it appear as if the character is static at some position and the background is moving. u need to make the camera and the game character which u are controlling move at the same speed. move the camera at whichever direction ur character is moving at the same speed.
5th Dec 2021, 3:54 AM
ACE
ACE - avatar