问题遇到的现象和发生背景
用python编写pygame代码时发生 'seturn' outside function的错误
用代码块功能插入代码,请勿粘贴截图
def runGame():
#setup veriables for the start of the game
board = getBlankBoard()
lastMoveDownTime = time.time()
lastMoveSidewaysTime = time.time()
lastFallTime = time.time()
movingDown = False #noet: there is no movingUp variable
movingLeft = False
movingRight = False
score = 0
level,fallFreq = calculateLevelAndFallFreq(score)
fallingPiece = getNewPiece()
nextPiece = getNewPiece()
while True:#game loop
if fallingPiece == None:
#No falling piece in play,so start a new piece at the top
fallingPiece = nextPiece
nextPiece = getNewPiece()
lastfallTime = time.time()#reset lastFallTime
if not isValidPosition(board,fallingPiece):
return
checkForQuit()
运行结果及报错内容
'return' outside function
return中的r被框红
我的解答思路和尝试过的方法
搜百度
我想要达到的结果
成功运行