First use Pygame to achieve the drawing function on the pit
Directly on the code
Import Pygame
Pygame.init ()
# Create a game window 480 *
Screen = Pygame.display.set_mode ((480,.))
# Draw a background image
# 1> loading image data
bg = pygame.image.load ("./images/background.png")
# 2> Blit drawing Images
screen.blit (BG, (0, 0))
# 3> Update screen display
pygame.display.update ()
While True:
Pass
pygame.quit ()
This code runs on Linux and Windows, but it's stuck in the Mac system.
Very headache, I want to appear the most likely because of the infinite loop caused by, so, I put the Loop code deleted. Rerun to see the drawn picture flashed past.
Then the problem must be in the loop.
So I took the "run Pygame appear stuck" problem, on the Internet to see such a piece of code
While True:
event = Pygame.event.poll ()
if Event.type = = Pygame. QUIT:
Pygame.quit ()
Exit ()
When I copy and paste this code, a miracle appears. The drawing window is working correctly.
For those who know the reason, please do not hesitate to enlighten
First use of Pygame on Mac (stuck)