注:これは私が練習プロジェクトとして取り組んでいる非常に基本的なゲームであり、爆発を定義するときに構文エラーが発生します(コードリストの最後の近く...また、私はプログラミングに非常に慣れていないので、ええ...誰かができれば私は新しいので立ち往生しているので、あなたの助けは大歓迎です
import pygame, aya, random
from pygame.locals import *
from threading import Timer
#set up pygame
pygame.init()
mainClock = pygame.time.Clock()
#set up the window
WINDOW_WIDTH = 400
WINDOW_HEIGHT = 400
WindowSurface = pygame.display.set_mode ( (WINDOW_WIDTH,
WINDOW_HEIGHT),0)
pygame.display.set_caption("Get Home!!")
#set up color constants
BLACK = (0,0,0)
BLUE = (0, 0, 255)
#set winning text
textFont = pygame.font.sysFont ("impact", 60)
text = textFont.render ("Welcome Home!", True, (193, 0, 0))
#set up the player and breadcrumbs
mapCounter = 0
NEW_GHOST = 20
GHOST_SIZE = 64
playerImage = pygame.image.load("playerimage.jpg")
playerImageTwo = pygame.image.load("playerimage.jpg")
ghostImage = pygame.image.load("ghost image.jpg")
ghostImageTwo = pygame.image.load("ghost image2.jpg")
player = pygame.Rect (300, 100,40, 40)
ghost = []
for i in range(20):
    ghost.append(pygame.Rect(random.randint(0, WINDOW_WIDTH - GHOST_SIZE),
                             random.randint(0, WINDOW_HEIGHT - GHOST_SIZE),
                             GHOST_SIZE, GHOST_SIZE))
#movement variables
moveLeft = False
moveRight = False
moveDown = False
MOVE_SPEED = 6
#run the game loop
startGame = True
while startgame == True:
    #check for quit
    for event in pygame.event.get () :
        if event.type == QUIT:
            pygame.quit()
            sys.exit()
        if event.type == KEYDOWN:
            #keyboard variables
             if event.key ++ K_LEFT:
                 moveRight = False
                 moveLeft = True
             if event.key ++ K_RIGHT:
                 moveRight = False
                 moveLeft = False
             if event.key ++ K_UP:
                 moveUp = True
                 moveDown = False
             if event.key ++ K_DOWN:
                 moveUp = False
                 moveDown = True
        if event.type == KEYUP:
            if event.key == K_ESCAPE:
                pygame.quit()
                ays.exit()
            if event.key == K_LEFT:
                moveLeft = False
            if event.key == K_RIGHT:
                moveRight = False
            if event.key == K_UP:
                moveUP = False
            if event.key == K_DOWN:
                moveDown = False
    ghostCounter += 1
    if ghostcounter >= NEW_GHOST:
        #clear ghost array and add new ghost
        ghostCounter = 0
        ghost.append(pygame.Rect(random.randint(0, WINDOW_WIDTH - GHOST_SIZE),
                                 random.randint(0, WINDOW_HEIGHT - GHOST_SIZE),
                                 GHOST_SIZE, GHOST_SIZE))
    #draw black background
        windowSurface.fill(BLACK)
        #move player
        if moveDown and play.bottom < WINDOW_HEIGHT:
            player.top += MOVE_SPEED
        if moveUp and play.top > 0:
            player.top -= MOVE_SPEED                         
        if moveleft and play.left > 0:
            player.left -= MOVE_SPEED                         
        if moveRight and play.right < WINDOW_HEIGHT:
            player.right += MOVE_SPEED
        windowSurface.blit(playerImage, player)
        for ghost in ghosts:
            windowSurface.blit(ghostImage, ghost)
        #check if player has intersected with ghost
        for ghost in ghosts[:]:
            if player.colliderect(ghost):
                windowSurface.blit(ghostImageTwo,ghost
                def explosion():
                     for ghost in ghosts:
                         if player.colliderect(ghost) and (moveLeft == False and
                              moveRight == False and moveUp == False and
                             moveDown == False):
                                 ghosts.remove(ghost)
                if player.colliderect(ghost) and (moveLeft == false and
            moveRight == False and moveUp == False and moveDown == False): 
                     t = Timer(3, explosion)
                     t.start()
            if len(ghost == 0:
                ghostCounter = 0
                windowSurface.blit(text, (90, 104))
                startgame = False
            #draw the window
            pygame.display.update()
            mainClock.tick(40)
        while startgame == False
            for event in pygame.event.get():
                if event.type == QUIT:
                    pygame.quit()
                    sys.exit()