【发布时间】:2018-04-29 21:12:23
【问题描述】:
我有这个代码:
import pygame, sys
from pygame.locals import *
pygame.init()
WHITE = (255,255,255)
class setup():
def set_resolution(x, y):
global surf
global screen
surf = pygame.Surface((x,y))
screen = pygame.display.set_mode((x,y))
pygame.display.set_caption("Lewis' Game")
pygame.draw.rect(screen, WHITE,(200,150,150,50))
def menu():
pass
setup.set_resolution(1024,768)
setup.menu()
while True:
for event in pygame.event.get():
if event.type == QUIT:
sys.exit()
由于某种原因,设置功能末尾的pygame.draw.rect(screen, WHITE,(200,150,150,50)) 实际上并没有出现,除非我显示桌面并将它们重新打开。我不确定为什么会发生这种情况,因为它以前从未发生过。应该提一下,我还在学习pygame,这段代码只是为了练习。
非常感谢。
【问题讨论】:
-
您需要致电
pygame.display.update()来绘制任何东西。 -
解决了!非常感谢!