Livl-Corporation / livl-pacman

Insane Pac-Man clone from © Livl Corporation 🕹️
MIT License
0 stars 1 forks source link

🌸 Pinky CHASE #92

Closed FranckG28 closed 1 year ago

FranckG28 commented 1 year ago

Image

Pinky: Nicknamed "Pinky", the pink ghost's character is described as one who is speedy. In Japan, he is characterized as machibuse, meaning "to perform an ambush", perhaps because Pinky always seems to be able to get ahead of you and cut you off when you least expect it.

He always moves at the same speed as Inky and Clyde, however, which suggests speedy is a poor translation of the more appropriate machibuse. Pinky and Blinky often seem to be working in concert to box Pac-Man in, leaving him with nowhere to run.

In chase mode, Pinky behaves as he does because he does not target Pac-Man's tile directly. Instead, he selects an offset four tiles away from Pac-Man in the direction Pac-Man is currently moving (with one exception). The pictures below illustrate the four possible offsets Pinky will use to determine his target tile based on Pac-Man's orientation:

Image

If Pac-Man is moving left, Pinky's target tile will be four game tiles to the left of Pac-Man's current tile. If Pac-Man is moving right, Pinky's tile will be four tiles to the right. If Pac-Man is moving down, Pinky's target is four tiles below.

Finally, if Pac-Man is moving up, Pinky's target tile will be four tiles up and four tiles to the left. This interesting outcome is due to a subtle error in the logic code that calculates Pinky's offset from Pac-Man. This piece of code works properly for the other three cases but, when Pac-Man is moving upwards, triggers an overflow bug that mistakenly includes a left offset equal in distance to the expected up offset (we will see this same issue in Inky's logic later).

Don Hodges' website has an excellent article giving a thorough, code-level analysis of this bug, including the source code and a proposed fix-click here to go there now.

Image

Pinky is the easiest ghost to exert control over thanks to his targeting scheme. By changing direction, you can dictate where Pinky will turn next when he is nearby (see above picture). If you are facing off closely with Pinky, he will turn before he reaches you if he can. This happens due to the fact Pac-Man has come close enough to Pinky for Pinky's target tile to now be behind him.

In the picture above, Pinky chooses to turn up at the intersection because moving left would have taken him further away from his target tile. The longest-lived example of this is the technique known as "head faking". This is where the player shakes the joystick to cause Pac-Man to rapidly change direction back and forth, hopefully causing a ghost to change course in the process.

As it turns out, the shaking is not necessary-one well-timed, quick reversal of direction towards Pinky just before he decides what to do at an upcoming intersection is all that is needed to get him off your tail.