There is a difference between having fun and taking a break. My office is near a park so when I get stuck on a problem or really frustrated I take a break by going for a walk, usually by the time I get back to the office I have figured out the solution to my problem or at least have a clear plan to go forwards - much more productive than just randomly changing things or forcing myself to write any old rubbish.
That was no joke in the 1980s. I'd start a compile and then read a book.
Well, it's no joke today either. If I compile my entire code-base, it takes about 1 hour 40 min., or 50 min. on 2 cores. Of course, you avoid full re-compilation as much as possible, but it can still mean frequent 15-30 minutes forced breaks (at least, from coding). The way a friend in the computer game industry described it, that cartoon seems quite accurate actually, they even have LAN game servers for Minecraft or Starcraft running continuously because at any given time there are always enough people who have nothing else to do while they wait for their code to compile.