0
저는 RPG를 만들려고합니다. 그러나 파이 게임이 표시되지 않을 때 항상 문제가 생깁니다. 저는이 비디오를 만드는 데 도움이되는 YouTube 비디오를 사용하고 있지만 제작자가 만든 것은 아닙니다. 컬러 모듈은 도움이 있지만, 그것은 단지 내가 거기 FPS 카운터를 만드는 더 나은 방법은 당신이 함수를 호출하고 디스플레이를 업데이트 할 pygame.display.update
뒤에 괄호를 추가 할 필요가파이 게임이 그리드 나 fps 카운터를 표시하지 않습니다
import pygame, sys, time
from Scripts.UltraColor import *
pygame.init()
cSec = 0
cFrame = 0
FPS = 0
tile_size = 32
fps_font = pygame.font.Font("C:\\Windows\\Fonts\\Verdana.ttf", 20)
def show_fps():
fps_overlay = fps_font.render(str(FPS), True, Color.Goldenrod)
window.blit(fps_overlay, (0,0))
def create_window():
global window, window_height, window_width, window_title
window_width, window_hight = 800, 600
window_title = "RPG"
pygame.display.set_caption(window_title)
window = pygame.display.set_mode((window_width, window_hight), pygame.HWSURFACE|pygame.DOUBLEBUF)
def count_fps():
global cSec, cFrame, FPS
if cSec == time.strftime("%S"):
cFrame += 1
else:
FPS = cFrame
cFrame = 0
cSec = time.strftime("%S")
create_window()
isRunning = True
while isRunning:
for event in pygame.event.get():
if event.type == pygame.QUIT:
isRunning = False
# LOGIC
count_fps()
# Render Graphics
window.fill(Color.Black)
# - Render Sinple Terrain Grid
for x in range(0, 640, tile_size):
for y in range(0, 480, tile_size):
pygame.draw.rect(window, Color.White, (x, y, tile_size + 1, tile_size + 1), 1)
show_fps()
pygame.display.update
pygame.quit()
sys.exit()