こんにちは、私はPygameを初めて使いました。左上にFPSカウンターが置かれた紫色のスクリーンを表示するウィンドウを作りたかったのです。ただし、何も表示されていない黒い画面が常に表示されます。コードを実行すると、エラーはまったく表示されません。再びPygameウィンドウに何も表示されない
import pygame
import time
from scripts.UltraColor import*
pygame.init()
currentSec = 0
currentFrame = 0
FramePerSec = 0
fps_font = pygame.font.Font("C:\\Windows\\Fonts\\Verdana.ttf", 20)
def count_FramePerSecond():
global currentSec, currentFrame, FramePerSec
# during the current second, this will record how many frames there are
if currentSec = time.strf("%S"):
currentFrame += 1
else:
FramePerSec = currentFrame
#records the frame that were added during the second
currentFrame = 0
#resets the counter back to zero so it can record during the next second
currentSec = time.strf("%S"):
#sets the current second variable to the current second
def show_FramesPerSecond():
fps_overlay = fps_font.render(str(FramesPerSecond), True, Color.Goldenrod)
window.blit(fps_overlay, (0,0))
def create_window():
global window, window_title window_height, window_width,
window_title = "Crappy RPG Game"
window_height = 700
window_width = 900
pygame.display.set_caption(window_title)
window = pygame.display.set_mode((window_height, window_width), pygame.HWSURFACE|pygame.DOUBLEBUF)
create_window():
is_gameRunning = True
while is_gameRunning:
for event in pygame.event.get():
if event.type == pygame.QUIT:
is_gameRunning = False
#Logic
count_FramePerSecond()
#Render Graphics:
window.fill(255,0,255)
show_FramesPerSecond()
pygame.display.update()
pygame.quit()
quit()
私は、スタックオーバーフローとpygameの両方に非常に新しいですので、申し訳ありません、それは明らかに間違い
あなたのコードは実行されていなくても、そのエラーはいっぱいです。 – Johannes