javascript - What is the principle of background movement in the game?
巴扎黑
巴扎黑 2017-06-27 09:18:47
0
2
1074

For example, if a person walks forward and the background moves backward, switch the canvas

巴扎黑
巴扎黑

reply all(2)
typecho

There can be many implementation principles, which will vary according to the theme and content of the game. The common things I know that are easier to implement:
1. Set a background image, tile the size of the main game area, set background-repeat to repeat, and change the coordinates of the background-position of the image through a timer (for example The background of the masturbation game on WeChat).
2. In addition, there are also some backgrounds with relatively complex backgrounds that can be spliced ​​together without gaps in a sub-container containing multiple background images. They can be positioned relative to the parent container, and the top and left values ​​of the sub-container can be changed by moving (similar to carousel images) principle), because people moving forward are actually caused by the movement of the "person" level within a limited area, and at the same time, the ground and background are positioned and moved in the opposite direction of the person at another same level.

小葫芦

My first impression is that of a 2D game like Super Mario. Its background is not continuous in two directions, left and right. I think the stupidest way is that the 2D background is very long, and then the camera keeps moving forward, haha.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template