I've been looking around and can't seem to find a solid answer to this question so:
I want to have a sprite that would follow another certain sprite, from my understanding of what I want I'll only need it to follow the Euclidean distance as a path, and have that update each frame.
The only way I could currently think of doing so would be to add speed depending on if the target had a current positive or negative x/y value and add speed accordingly but I can't help but feel that would be incredibly inefficient and perhaps not even work that well.
So I was just wondering if there would be any better way to do it?
What the sprite (follower) would look like:
import pygame
import global_vars
import enemy
from global_vars import WHITE
from enemy import Enemy
class Projectile(pygame.sprite.Sprite):
def __init__(self, x, y):
pygame.sprite.Sprite.__init__(self)
self.image= pygame.Surface((x,y))
self.image.fill(WHITE)
self.rect = self.image.get_rect()
self.target_enemy = Enemy.enemy #don't actually know if I need that first Enemy in that line...
self.x_cspeed = 0 #current x speed
self.y_cspeed = 0 #current y speed
def update(self):
target = self.target_enemy
Sorry if I'm asking this in the wrong way or something, usually don't ask for help online...