Я использовал видео на YouTube, чтобы сделать эту платформерную игру. Все атрибуты и параметры были определены, но все равно появляется ошибка. Вот мой блок кода:
def update(self):
# Game Loop Update
self.all_sprites.update()
# Check if player hits a platform only if falling
if self.player.vel.y > 0:
hits = pg.sprite.spritecollide(self.player, self.platforms, False)
if hits:
self.player.pos.y = hits[0].rect.top + 1
self.player.vel.y = 0
# If player reaches top 1/4 of screen
if self.player.rect.top <= HEIGHT / 4:
self.player.pos.y += abs(self.player.vel.y)
for plat in self.platforms:
plat.rect.y += abs(self.player.vel.y)
if plat.rect.top >= HEIGHT:
plat.kill()
Это класс игрока для дополнительной информации:
class Player(pg.sprite.Sprite):
def __init__(self, game):
pg.sprite.Sprite.__init__(self)
self.game = game
self.image = pg.Surface((30,40))
self.image.fill(YELLOW)
self.rect = self.image.get_rect()
self.rect.center = (WIDTH/2, HEIGHT/2)
self.pos = vec(WIDTH/2, HEIGHT/2)
self.vel = vec(0,0)
self.acc = vec(0,0)
В шестой строке, приведенной в коде, консоль выдает ошибку: AttributeError: 'bool' object has no attribute 'vel'
Кто-нибудь может помочь? Скажите мне, если мне нужно предоставить больше информации.