0

This is my code:

import pygame

# Initialize
pygame.init()
screenInfo = pygame.display.Info()
displayWidth = screenInfo.current_w  # 1920 on my pc
displayHeight = screenInfo.current_h  # 1080 on my pc
gameDisplay = pygame.display.set_mode((displayWidth, displayHeight), pygame.FULLSCREEN)
quit_game = False

def HandleEvents():
    """
    Handle quit requests from user
    """
    global quit_game
    for event in pygame.event.get():
        if event.type == pygame.QUIT or (event.type == pygame.KEYDOWN and event.key == pygame.K_q):
            quit_game = True


while not quit_game:
    HandleEvents()
    gameDisplay.fill((0, 0, 0))
    pygame.draw.circle(gameDisplay, (255, 255, 255), (displayWidth/2, displayHeight/2), 20)
    pygame.display.update()

When I run it, the white circle appears in the middle of the screen as intended, but when I switch to another window by pressing alt+esc and then re-enter the program by pressing on it's icon the white circle moves to the right and stays that way no matter how much I re-enter the program again.

When I run the program at first,

When I re-enter the program

Stonewow
  • 3
  • 1
  • 2
  • Does this also happen in windowed mode? – ChatterOne Jul 30 '18 at 08:14
  • No, only on fullscreen mode and somewhat high resolutions. it won't happen if i'm setting the display surface object to be: pygame.display.set_mode((640, 480), pygame.FULLSCREEN) –  Stonewow Jul 30 '18 at 08:35

0 Answers0