import pygame
import sys
from pygame.locals import *
DISPLAY_SURF = pygame.display.set_mode((640,480))
#Sets the resolution to 640 pixels by 720 pixels
class Game:
def __init__(self):
pygame.init()
self.FPS = 60
self.fps_clock = pygame.time.Clock()
self.surface = pygame.display.set_mode((640, 480))
pygame.display.set_caption("The Hunt")
img = pygame.image.load("Graphics/background.png")
self.surface.blit(img)
#This class sets the basic attributes for the window.
#The clock is set to 60 and the name of the window
#is set to The Hunt which is a working title for my project
def run(self):
while True:
pygame.display.update()
self.fps_clock.tick(self.FPS)
self.process_game()
#This updates the window display to refresh every clock tick
def process_game(self):
for event in pygame.event.get():
if event.type == QUIT:
pygame.quit()
sys.exit()
game = Game()
#This creates an instance of the class Game which gives all the attributes
# and behaviours to this instance
game.run()
#Calling this function generates a window with the attributes defined.
私はいくつかの助けが必要です。私はすでにそれが同じフォルダにあるかどうかをチェックしています。そのファイルは間違いなくpngであり、すべてのフォルダ名と送り先が正しく綴られています。私はどんな提案にも開放しています。私は何が間違っているのか分かりません。パイゲームウィンドウを開くコード
ようこそスタックオーバーフロー!デバッグの助けを求める質問(「なぜこのコードは動作しませんか?」)には、目的の動作、特定の問題またはエラー、および質問自体の中でそれを再現するのに必要な最短コードが含まれていなければなりません。明確な問題文がない質問は、他の読者にとって有用ではありません。参照:[mcve]を作成する方法。あなたの*質問*を改善するために[編集]リンクを使用してください - コメントでより多くの情報を追加しないでください。ありがとう! – GhostCat
あなたはいくつかのコードと質問のタイトルを載せます。あなたは、あなたのコードが何をしているべきか、あなたが実際にそれを観察していることを私たちに語っていません。 – GhostCat