So I'm getting this error when I compile, I don't understand though because I've got 2 identical classes, one works fine the other throws out this error.
if self.currentState2==1: NameError: name 'self' is not defined
class EnemyShip(pygame.sprite.Sprite):def __init__(self, (x, y), playerShip):pygame.sprite.Sprite.__init__(self)self.image = pygame.image.load("enemy.png")self.image = self.image.convert()tranColor = self.image.get_at((1, 1))self.image.set_colorkey(tranColor)self.rect = self.image.get_rect()self.enemyX = float(x)self.enemyY = float(y)self.ship = playerShipself.count = 0self.currentState2 = 0def update(self):self.count += 1x_component = self.ship.rect.centerx-self.enemyXy_component = self.ship.rect.centery-self.enemyYdistance = math.hypot(x_component, y_component)if distance < 100:self.currentState2 = 1print distanceelif distance > 100:self.currentState2 = 0print "test2"if self.count < 600:self.caculateNextPosition()self.rect.center = (self.enemyX, self.enemyY)elif self.count < 600:self.caculateNextPositionEvade()self.rect.center = (self.enemyX, self.enemyY)else:self.count = 0 def caculateNextPosition(self):shipX = self.ship.rect.centerxshipY = self.ship.rect.centeryif self.currentState2==1:if self.enemyY < shipY:self.enemyY += 4elif self.enemyY > shipY:self.enemyY -= 4if self.enemyX < shipX:self.enemyX += 4elif self.enemyX > shipX:self.enemyX -= 4elif self.currentState2==0: if self.enemyY < shipY:self.enemyY += 0elif self.enemyY > shipY:self.enemyY -= 0if self.enemyX < shipX:self.enemyX += 0elif self.enemyX > shipX:self.enemyX -= 0