I am using the verbatim code from a tutorial to trigger an explosion when a projectile collides with a Trump sprite. I have pasted below the explosion class, the section of code where the images for the explosion are loaded, and the code where I do the collision in the update section. I am getting the following error self.image = explosion\_anim[self.size][0] NameError: name 'explosion\_anim' is not defined. I started to think it was because I define explosion\_anim later in the code but the guy in the tutorial has his code like mine. If someone could please help.

```
class Explosion(pg.sprite.Sprite):
    def __init__(self, center, size):
        pg.sprite.Sprite.__init__(self)
        self.size = size
        self.image = explosion_anim[self.size][0]
        self.rect = self.image.get_rect()
        self.rect.center = center
        self.frame = 0
        self.last_update = pg.time.get_ticks()
        self.frame_rate = 50

    def update(self):
        now = pg.time.get_ticks()
        if now - self.last_update > self.frame_rate:
            self.last_update = now
            self.frame += 1
            if self.frame == len(explosion_anim[self.size]):
                self.kill()
            else:
                center = self.rect.center
                self.image = explosion_anim[self.size][self.frame]
                self.rect = self.image.get_rect()
                self.rect.center = center

```

I forgot to note that this stuff is under load\_images. It might have not been the best place to put it.
========================================================================================================

```
def load_images
        #other images loaded here
        explosion_anim = {}
        explosion_anim['lg'] = []
        explosion_anim['sm'] = []
        for i in range(9):
            filename = 'regularExplosion0{}.png'.format(i)
            img = pg.image.load(filename).convert()
            img.set_colorkey(BLACK)
            img_lg = pg.transform.scale(img, (75, 75))
            explosion_anim['lg'].append(img_lg)
            img_sm = pg.transform.scale(img, (32, 32))
            explosion_anim['sm'].append(img_sm)

```

The section for the code where the collision is performed is below. 

```
 def update:
       TrumpHits = pg.sprite.spritecollide(self.trump, self.projectiles, True)
        for hit in TrumpHits:
            print("TRUMP HIT!!!")
            expl = Explosion(hit.rect.center, 'lg')
            all_sprites.add(expl)

```