Difference between revisions of "Worm Walking"
From Worms Knowledge Base
CyberShadow (Talk | contribs) m (what was that linebreak doing there?) |
(Add link to Skipwalking) |
||
Line 64: | Line 64: | ||
Once the warmup has finished, the walk loops with a 1.00 second period. Each loop, the worm travels exactly 27 pixels. | Once the warmup has finished, the walk loops with a 1.00 second period. Each loop, the worm travels exactly 27 pixels. | ||
Skipping forces the warmup to repeat each time. | Skipping forces the warmup to repeat each time. | ||
+ | |||
+ | === See also === | ||
+ | * [[Skipwalking]] | ||
[[Category:Miscellaneous research notes]] | [[Category:Miscellaneous research notes]] |
Revision as of 02:53, 4 March 2013
Walking can be performed in the game using the Left & Right arrow keys when you have control of your worm. The horizontal shift applied to the worm mask during a walk is determined by which frame gets displayed in the walking sprite.
Frame changes in the walking animation are caused by your controls, not by a FPS timer. This makes it possible for the sprite to have a FPS rate that is not a whole number, which happens to be the case. There are 15 frames in the sprite, 13 of which apply horizontal motion, and these get cycled 3 times per second. Worms runs at a steady 50 FPS. Not having a whole number for the rate of change means that the number of the frames in a cycle will vary. In 3 cycles, 2 cycles will have 17 frames and 1 will have 16 frames. (17 + 17 + 16 = 50)
(1 - (15 × 3)/50) × 100% = 10%
So 10% of the frames in the walking sprite get repeated with no motion applied to them. According to one of Deadcode's posts, the movement (pixels) in one walk cycle would look something like this:
- Frame 1: 0.50
- Frame 2: no motion
- Frame 3: 0.50
- Frame 4: 0.50
- Frame 5: 0.50
- Frame 6: 0.50
- Frame 7: 1.50
- Frame 8: 1.75
- Frame 9: 1.50
- Frame 10: 1.25
- Frame 11: 0.25
- Frame 12: no motion
- Frame 13: 0.25
- Frame 14: 0.25
- Frame 15: 0.25
- Frame 16: no motion
- Frame 17: no motion
- Frame 18: no motion
Worms wouldn't be very fun if your worm stopped moving every time a pixel got in your way. So to keep movement smoother, the game's physics coding initiates upto an 8 pixel check to see if your worm can be moved ontop of the collided pixel(s). Your worm gets shifted upwards if a negative collision is returned from the loop (1 to 8). If not, your worm will stop moving.
The above image demonstrates how the game calculates what to do when a collision occurs in the walking sequence. White refers to the worm mask, Green refers to the terrain mask, Blue refers to pixels where the two layers have collided, and the Red Arrow refers to the horizontal shift occuring in the frame.
Similarly, to prevent your worm from walking on thin air, the game needs to detect if there are degradations in the landscape as you are walking. This is done by initiating an 8 pixel check below the worm mask. Your worm gets shifted downwards if a positive collision is returned from the loop (1 to 8). If not, the gravity formula gets applied to the worm and the falling sequence is initiated.
Phases of worm walking
- 0.00 second: +0.50 pixel (warmup)
- 0.02 second: no motion (warmup)
- 0.04 second: +0.50 pixel
- 0.06 second: +0.50 pixel
- 0.08 second: +0.50 pixel
- 0.10 second: +0.50 pixel
- 0.12 second: +1.50 pixels
- 0.14 second: +1.75 pixels
- 0.16 second: +1.50 pixels
- 0.18 second: +1.25 pixels
- 0.20 second: no motion
- 0.22 second: +0.25 pixel
- 0.24 second: no motion
- 0.26 second: +0.25 pixel
- 0.28 second: +0.25 pixel
- 0.30 second: +0.25 pixel
- 0.32 second: no motion
- 0.34 second: no motion
- 0.36 second: no motion
Once the warmup has finished, the walk loops with a 1.00 second period. Each loop, the worm travels exactly 27 pixels. Skipping forces the warmup to repeat each time.