5

I just recently learned Python and Pygame library.

I noticed that the rendering and main loop is automatically paused when I click and hold on the window menu bar (the bar with the title/icon).

For example, in a snake game, the snake will be moving every frame. When I click and hold (or drag) the window menu, the snake is not moving anymore and the game is "paused". When I release it, it resumes.

Is there a way to let the game NOT pause when I drag the windows menu bar?

raybaybay
  • 647
  • 6
  • 16

2 Answers2

2

When you drag the window only the event queue gets stopped. So if your update/draw is not coupled with the event queue, they will not be paused.

from pygame.locals import *
import pygame
import sys

import time;
import random;

pygame.init()
DISPLAYSURF = pygame.display.set_mode((530, 212))

while True:
    t = random.random();
    t *= 255;
    for event in pygame.event.get():        
        if event.type == QUIT:
            pygame.quit()
        print event;

    DISPLAYSURF.fill((int(t) % 255, int(t) % 255, int(t) % 255));
    pygame.display.update()
Joshua Grigonis
  • 748
  • 5
  • 18
n2omatt
  • 70
  • 5
0

This one is pretty easy, its seems you forgot to add a event callback. state 1 while (sate != 0): for event in pygame.event.get():