Difference between revisions of "Worm Walking"

From Worms Knowledge Base

Jump to: navigation, search
 
m
 
(11 intermediate revisions by 6 users not shown)
Line 1: Line 1:
 +
{{ParentArticle|[[:Category:Miscellaneous research notes]]}}
 +
 +
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%
 +
<!--math>\left ( 1 - \frac{15 \times 3}{50} \right ) \times 100% = 10%</math-->
 +
 +
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
 +
 
[[Image:Walkexample.png]]
 
[[Image:Walkexample.png]]
  
Line 8: Line 39:
  
 
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.
 
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.
 +
 +
== See also ==
 +
* [[Skipwalking]]
 +
* [[Worm]]
 +
 +
== External links ==
 +
* [https://youtu.be/3qnWWKE2IhE Walking and jumping tutorial video] by [[User:Mablak|Mablak]]
 +
 +
[[Category:Miscellaneous research notes]]

Latest revision as of 15:32, 22 May 2022

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

Walkexample.png

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.

See also

External links

Personal tools