class Missle(pygame.sprite.Sprite): """This is the missle fired from user """ #Because of so many missles being fired we want to load image once image = None #Initialization def __init__(self, destination): pygame.sprite.Sprite.__init__(self) #call Sprite initalizer if Missle.image is None: #Is this the first time making a missle Missle.image, self.rect = load_image('Missle.png', (255, 255, 255, 0)) #Well then load the image self.image = Missle.image #Set the single image to the global image self.rect = self.image.get_rect() #get the rectangle from the single image self.rect.center = (195,400) #All missles get launched from the command post self.vector = GetVector(destination,self.rect.center) #self.path = Bresenham((195,400),destination) #Get the missles course self.dest = destination #Get the missles destination that is givien self.image = transform.rotate(Missle.image, GetMissleAngle(destination, self.rect.center)) #Rotate the image so it travels to the destination straight self.counter = 0 #Counting Variable (used in Update) def update(self): #Moves the missle towards dest on path self.rect.centerx -= self.vector[0] self.rect.centery -= self.vector[1]def GetVector(pA, pB): Vmx = pB[0] - pA[0] Vmy = pB[1] - pA[1] divisor = math.sqrt( (pB[0] - pA[0])**2 + (pB[1] - pA[1])**2) Vnorm = (Vmx / divisor, Vmy / divisor) Vmove = Vnorm return Vmove