【发布时间】:2017-08-09 08:48:44
【问题描述】:
我昨天发布了这个问题,但我不小心发布了错误的代码。该程序仍然无法正常工作。我正在尝试使用 pygame 制作游戏,而我的图片来自一个名为 Pixel Art Studio 的应用程序。但是,当我运行代码时,我没有收到任何错误消息,只是一个空白的白屏。我正在关注一本名为 Hello World 的 Python 编程书,但这是一个原始程序。请告诉我我做错了什么,这是我的代码。
import pygame, sys
guyimages = ['swordsmanguy.pxm','swordsmanstabup.pxm','swordsmanstabstraight.pxm','swordsmanstabdown.pxm']
legsimages = ['swordsman.legs1.pxm','swordsman.legs2.pxm','swordsman.legs3.pxm','swordsman.legs2.3.pxm','swordsman.legs2.2.pxm']
class avatar(pygame.sprite.Sprite):
def __init__(self):
pygame.sprit.Sprite.__init__(self)
self.image = pygame.image.load(guyimages["swordsmanguy.pxm"])
self.rect = self.image.get_rect()
self.rect.center = [250, 250]
self.angle = 0
def animate():
screen.fill([255,255,255])
screen.blit(avatar.image, avatar.rect)
pygame.display.flip
pygame.init()
screen = pygame.display.set_mode([960, 640])
running = True
while running:
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False
animate()
pygame.quit()
【问题讨论】:
标签: python