2017-10-21 59 views
0

出於某種原因,當我使用下面的代碼:需要與Pygame的援助和創建窗口

import pygame, sys 

pygame.init() 

def create_window(): 

    global window, window_height, window_width, window_title 
    window_width, window_height = 1280, 720 
    window_title = "The Adventure of Nate" 
    pygame.display.set.caption(window_title) 
    window = pygame.display.set_mode((window_width, window_height, pygame.HWSURFACE|pygame.DOUBLEBUFF) 

create_window() 

isrunning = True 

while isrunning == True: 
     for event in pygame.event.get(): 
      if event.type == pygame.QUIT: 
       isRunning = False 

     window.fill(0, 0, 0) 

     pygame.display.update() 


pygame.quit() 
sys.exit() 

我收到以下錯誤:

C:\Python3.6\python.exe "C:/Users/home/PycharmProjects/Basic RPG/Base Game.py" File "C:/Users/home/PycharmProjects/Basic RPG/Base Game.py", line 16 create_window() ^SyntaxError: invalid syntax

Process finished with exit code 1

如果有人在這個問題上經驗豐富,能他們幫助我糾正我的代碼。

(PS:這是沒有幫助我的第一次編碼,很抱歉,如果我的代碼是所有的地方XD)

+1

您在調用'pygame.display.set_mode'時沒有關閉圓括號。 –

回答

0

你錯過了在線路)window = pygame.display.set_mode((window_width, window_height, pygame.HWSURFACE|pygame.DOUBLEBUFF)

應該window = pygame.display.set_mode((window_width, window_height), pygame.HWSURFACE|pygame.DOUBLEBUFF)