【发布时间】:2014-11-21 16:34:59
【问题描述】:
我正在尝试使用 Pygame 和 Python 3.4 创建一个小游戏。 我一直在尝试创建一个角色精灵,但是,即使有大量的在线教程,我也没有设法让我的代码正常工作。我知道窗口本身可以正常加载,但我不知道为什么会出现错误。
这是我的代码:
import pygame, sys, os
from pygame.locals import *
class player(pygame.sprite.Sprite):
def __init__(self,img):
pygame.sprite.Sprite.__init__(self)
self.image = img
self.rect = self.image.get_rect()
pygame.init()
DISPLAYSURF = pygame.display.set_mode((1000,750))
pygame.display.set_caption('Hello world')
img = pygame.image.load("pixel art\RPGchar.png").convert_alpha()
while True: #game loop
for event in pygame.event.get():
if event.type == QUIT:
pygame.quit()
sys.exit()
player.draw(DISPLAYSURF)
player.update()
pygame.display.flip()
任何帮助都会让我非常感激。 tnx
【问题讨论】:
标签: pygame python-3.4