I'd record the gameplay to video, then import the video file to Photoshop. Using Photoshop, I'd look for a loop point then delete the remaining frames. I then exported the PNG frames and combine them again in a gif editor. The result is a looping gif you see.