One of the mechanics of our video game is that all of the playable characters follow the same path, as controlled by the player. You can see what I mean by watching the video below.
It was somewhat tricky programming the delayed mechanic, and here’s why: When I originally programmed it, I created 4 Boolean variables (w_delay, a_delay…) which would become True a couple seconds after a WASD key was pressed, and become False a couple seconds after a key was released.
The problem with this approach was that the data was “lossy”, or in other words, not preserving all of the keystrokes inputted by the player. Because of this, the second character would follow the first character in a perpendicular line, instead of mimicking every movement. So if the first character moved to the right and then up, the second would move at a 45 degree angle.
To fix this, I created a list containing the Boolean variables ([w_delay, a_delay … ]), and programmed the second character to move based on the entire list (rather than moving based on each of the keystrokes individually). As a result, the second character’s movement is “lossless” and true to the player’s keystrokes.
Pretty cool, huh?