So I first define some variables:
Then in a game update loop:
Every
round(1000 / recording_fps)
(which works out to be 33ms) it will make a temporary image that is half the screen size (plus one for border) and draw the screen to somewhere past the very top left, so that the center ends up being in the actual image. Then it draws the border and inserts it to the list of the last 2 seconds, which is the list recording_frames
. Then if the length of the recording is over (2 * recording_fps)
(which works out to be 60 frames) then it removes the oldest frame so there are always 2 seconds in memory.
When you lose, it first splits up the recording into the first second and second second. I have no idea why I did that lol.
Then creates the sprite that will play back the last two seconds.
Then it makes the “RIP” text: (which is just a text sprite)
Then it plays the melody, the recording, and then the actual game over: