これは pygame の画面の私のコードですが、黒い画面以外は何も表示されません。エラーはありませんが、私は Python を初めて使用するので、何が問題なのか教えていただけますか?
import pygame, sys
from pygame.locals import*
pygame.init()
マイスクリーン
DISPLAYSURF=pygame.display.set_mode((300,200), 0, 32)
pygame.display.set_caption('WorldMaker')
色
BLACK=(0,0,0)
WHITE=(255,255,255)
RED=(255, 0, 0)
GREEN=(0,255,0)
BLUE=(0,0,255)
YELLOW=(255,255,0)
テキストと線
DISPLAYSURF.fill(WHITE)
pygame.draw.line(DISPLAYSURF, BLACK, (0,30), (300,30), 3)
pygame.draw.line(DISPLAYSURF, BLACK, (200,0), (200,200), 3)
myfont=pygame.font.SysFont('Eras Bold ITC', 20)
label = myfont.render('WorldMaker', 1, BLACK)
DISPLAYSURF.blit(label,(50,10))
label1 = myfont.render('Store', 1, BLACK)
DISPLAYSURF.blit(label1,(225,10))
私のスプライト
これは私が最も問題を抱えている部分であり、原因であるか、メインループである可能性があると思います。
class B(pygame.sprite.Sprite):
def __init__(self):
pygame.sprite.Sprite.__init__(self)
self.image=pygame.image.load('Character.png').convert()
self.rect = self.image.get_rect()
self.rect.topleft=[150,50]
def update(self):
self.rect.y +=1
B_list=pygame.sprite.Group()
all_sprites_list = pygame.sprite.Group()
b=B()
B_list.add(b)
#Main Loop
while True:
B.update(b)
for event in pygame.event.get():
if event.type == QUIT:
pygame.quit()
sys.exit()
pygame.display.update()