Blinking

From Ukikipedia
Jump to navigation Jump to search

You may be looking for Hitstun blinking, the cause of Pause buffered hitstun.

Blinking is the phenomenon in which many objects appear to blink their eyes.

The only creatures that blink are Mario, Peach, Bowser, Eyerok, Pokeys, Koopas of all kinds (including Koopa the Quick), Goombas, Lakitu, Penguins of all kinds, Bob-ombs, Pink Bob-ombs, Mr. I, and Yoshi. Of these, Mr. I and Eyerok blink based on Mario's interactions with them. All other creatures blink idly.


Blinking Systems

There are several different blinking systems the game uses to determine when an object should blink.

Mario/Peach

The Mario/Peach blinking system uses the game's animation timer to determine when Mario and Peach should blink. Mario and Peach each have a blinking animation that lasts 14 frames, and the game performs bitwise calculations each frame to determine whether or not to play the animation. These calculations make it so that Mario will blink every 64 frames, and Peach will blink every 64 frames. However, Peach's blinking animation is offset from Mario's by 32, meaning that they will never blink at the same time.

Bowser

If the difference between Bowser's moving angle and his angle to Mario is greater than 45 degrees, Bowser looks to the side and does not blink unless his blinking animation has already started. If Bowser is not looking to the side, he will do his blinking animation every 64 frames. The blinking animation takes 16 frames to complete, 4 of which have Bowser's eyes partially closed, 4 of which have Bowser's eyes completely closed, and 8 of which have Bowser's eyes open. Because Bowser's blinking counter increments when the game is paused, Bowser will blink when the game is paused if he is not looking to the side.

Penguins

The Penguins (small and large) use the global timer to control their blinking. The Penguin's blinking timer is taken from the global timer modulo 50. When the timer is greater than 43, the Penguin starts to blink. The Penguin's eyes are partially closed for 2 frames, then closed for 2 frames, then partially closed for 3 frames, and then open again. Thus, the Penguins blink every 50 frames and the animation lasts 7 frames. Since the global timer increments while the game is paused, Penguins will blink even when the game is paused.

Common Enemy

This system is used by Goombas, Pokeys, Lakitus, Koopas, and Koopa the Quick. This system uses a countdown timer with a randomly generated number. When the countdown timer is below a certain value, the object blinks, and then calls RNG to determine a new number to begin the countdown from. Goombas blink when the countdown is from 5 to 0, and the countdown is reset to a number between 30 and 79. Pokeys blink when the countdown is from 4 to 0, and the countdown is reset to a number between 30 and 89. Lakitus blink when the countdown is from 4 to 0, and the countdown is reset to a number between 20 and 59. Koopas blink when the countdown is from 4 to 0, and the countdown is reset to a number between 20 and 69. Koopa the Quick blinks when the countdown is from 3 to 0, and the countdown is reset to a number between 10 and 24.

RNG

This system is used by Bob-ombs and Yoshi. Bob-ombs call RNG every frame to determine if they should blink. Specifically, it calls for a random float between 0 and 1, which is then multiplied by 100 and cast to an integer. If the integer it is cast to is 0 (the random float is less than 1/100), the Bob-omb begins its blinking animation. The animation lasts 15 frames, after which the game calls for RNG again. Thus, Bob-ombs and Yoshi will blink about once every 100 frames on average. However, since this is completely based on RNG, in practice this can be made much shorter or longer with RNG manipulation.

References

"Blinking" by Pannenkoek2012

Mario's blinking code

Peach's blinking code

Bowser's Eye code

Penguin blinking code

Common enemy blinking code

Bob-omb blinking code