Hey there! I am currently trying to learn pygame. I am watching a tutorial by Clear Code (Creating a platformer in Pygame with a camera, collisions, animation states and particle effects - YouTube) ← video link, and I am having trouble at (1:11:23-1:11:46) ← timestamp. The error I get when I type in that code on line 10 is IndexError: list index out of range. Any idea’s on how I can fix this and if this is even possible to do on replit? Thanks!
(https://replit.com/@notomen/Mario-Maker#player.py)
import pygame
from support import import_folder
class Player(pygame.sprite.Sprite):
def __init__(self, pos):
super().__init__()
self.import_character_assets()
self.frame_index = 0
self.animation_speed = 0.15
self.image = self.animations['idle'][self.frame_index]
self.rect = self.image.get_rect(topleft = pos)
#Player Movement
self.direction = pygame.math.Vector2(0, 0)
self.speed = 8
self.gravity = 0.8
self.jump_speed = -16
def import_character_assets(self):
character_path = '../graphics/character/'
self.animations = {'idle':[], 'run':[], 'jump':[], 'fall':[]}
for animation in self.animations.keys():
full_path = character_path + animation
self.animations[animation] = import_folder(full_path)