0
我正在做一個平臺遊戲,我剛開始它,並且遇到了語法錯誤。該代碼是在這裏:令人討厭的無效語法
import pygame, sys
from player import *
from constants import *
class Game():
def __init__(self):
pygame.init()
self.screen = pygame.display.set_mode((0, 0), pygame.FULLSCREEN)
pygame.display.set_caption('GAME')
self.font = pygame.font.Font('data/font/orecrusherexpanded.ttf', 50)
self.black = (0, 0, 0)
self.blue = (50, 60, 100)
self.player = Player(250, 250)
def run(self):
clock = pygame.time.Clock()
RUNNING = True
while RUNNING:
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
sys.exit()
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_ESCAPE:
pygame.quit()
sys.exit()
fps = 60
self.screen.fill(self.blue)
self.player_move()
self.player.update()
self.player.handle_events(event)
self.player.render(self.screen)
self.screen.blit(self.font.render("FPS: " + str(clock.get_fps()), 1, (255, 0, 0), (0,0))
clock.tick(fps)
pygame.display.flip()
def player_move(self):
self.player.rect.x += self.player.velX
self.player.rect.y += self.player.velY
Game().run()
凡說clock.tick(FPS)當我運行程序錯誤亮點時鐘和彈出說語法無效!謝謝你的幫助。
你缺少在該行正上方此 – Wolf