# PYGAME - Sprite movement seize to function when entire X and Y span is reviewed

I've created an sprite class that has a detection radius checking if the player enters the zone. If yes, the sprite moves towards the player. It works perfectly fine when the sprite checks for three directions (X is greater, X is lower, Y is greater/lower), in other words, the sprite only moves up and down if all four directions are enabled..

Here is my code for the move function:

def move(self):
target_x, target_y = self.target.pos

if self.mob_wc + 1 <= 24:

if self.pos_x < target_x:
self.vel += vec(self.speed, 0)
self.image = self.game.orc_mob_walkRight[self.mob_wc//6]
self.mob_wc += 1

elif self.pos_x > target_x:
self.vel = vec(-self.speed, 0)
self.image = self.game.orc_mob_walkLeft[self.mob_wc//6]
self.mob_wc += 1

if self.pos_y > target_y:
self.vel = vec(0, -self.speed)
self.mob_wc += 1

elif self.pos_y < target_y:                   <-- if this condition is disabled
self.vel = vec(0, self.speed)                 The sprites move perfectly upwards
self.mob_wc += 1                              towards the player, shifting between
moving On X and moving on Y.
else:                                                     However, if it is enabled, the
self.mob_wc = 0                                       sprites ONLY move on the Y field



Here is my code for the update function:

    def update(self):
self.rect = self.image.get_rect()
self.rect.center = self.pos
self.pos += self.vel * self.game.dt

self.pos_x, self.pos_y = self.pos

target_dist = self.target.pos - self.pos