1
當我運行此代碼時,它顯示一個空白的黑色窗口,它說x
未定義。在pygame中打開一個空白的黑色窗口
import pygame,sys
from pygame.locals import *
pygame.init()
screen = pygame.display.set_mode((800,500))
screen.fill((255,255,255))
#basic stuff
pygame.draw.line(screen,(0,0,0),(500,0),(500,500))
pygame.draw.rect(screen, (0,255,0), (20,50,460,420))
#pygame.draw.line(screen, (0,0,0), (500,0),(500,500))
#pygame.draw.line(screen, (0,0,0), (500,500),(0,500))
#draw
while 1:
for event in pygame.event.get():
if event.type == QUIT:
pygame.quit()
sys.exit()
if event.type == MOUSEBUTTONDOWN:
pos = pygame.mouse.get_pos()
x = int(pos[0]//20)
y = int(pos[1]//20)
j = int(x*20+20)
l = int(y*20+20)
print(x+1,' ',y+1)
if x > 2 and y > 3 and x < 24 and y < 24:
pygame.quit()
其不是顏色。它的劑量不作出任何強硬的線條給我的命令
myfont = pygame.font.SysFont("monospace", 20)
label = myfont.render("Allameh helli 3 stock exchange group",1,0,0,0))
screen.blit(label, (30, 10))
什麼是我的錯誤(S)在這裏,使我無法使得畫面白色和提高的錯誤?
感謝您的幫助。 – kiant