目前为止,Player的站立、行走、跳跃都是动画了,只有跳板(即:Platform类)还是难看的矩形,这节我们把Platform也换成图片:
原来的Platform类长这个样子:
1 class Platform(pg.sprite.Sprite): 2 def __init__(self, x, y, w, h): 3 pg.sprite.Sprite.__init__(self) 4 self.image = pg.Surface((w, h)) 5 self.image.fill(GREEN) 6 self.rect = self.image.get_rect() 7 self.rect.x = x 8 self.rect.y = y