My enemy only moves when my player image is scrolling [VIDEO](https:
first I made my enemy class
```
class enemy:
def __init__(self,x,y,height,width,end):
self.x = x
self.y =y
self.esright = [pygame.image.load("esright1.png"),
pygame.image.load("esright1.png"),
pygame.image.load("esright2.png"),
pygame.image.load("esright3.png"),
pygame.image.load("esright4.png"),
pygame.image.load("esright5.png"),
pygame.image.load("esright6.png"),
pygame.image.load("esright7.png"),
pygame.image.load("esright8.png"),
pygame.image.load("esright9.png"),
pygame.image.load("esright10.png"),
pygame.image.load("esright11.png"),
pygame.image.load("esright12.png"),
pygame.image.load("esright13.png"),
pygame.image.load("esright14.png"),
pygame.image.load("esright15.png"),
pygame.image.load("esright16.png"),
pygame.image.load("esright17.png"),
]
self.esleft = [pygame.image.load("esleft1.png"),
pygame.image.load("esleft1.png"),
pygame.image.load("esleft2.png"),
pygame.image.load("esleft3.png"),
pygame.image.load("esleft4.png"),
pygame.image.load("esleft5.png"),
pygame.image.load("esleft6.png"),
pygame.image.load("esleft7.png"),
pygame.image.load("esleft8.png"),
pygame.image.load("esleft9.png"),
pygame.image.load("esleft10.png"),
pygame.image.load("esleft11.png"),
pygame.image.load("esleft12.png"),
pygame.image.load("esleft13.png"),
pygame.image.load("esleft14.png"),
pygame.image.load("esleft15.png"),
pygame.image.load("esleft16.png"),
pygame.image.load("esleft17.png"),
]
self.esright = [pygame.transform.scale(image,(image.get_width()
self.esleft = [pygame.transform.scale(image,(image.get_width()
self.height = height
self.width = width
self.anim_index = 0
self.distance = 80
self.speed = 8
self.vel = 3
self.path = [x,end]
self.walking_index = 0
self.rect = pygame.Rect(x,y,height,width)
```
then I made the function for it to move but as you can see on the video it only moves left and right if my player moves
```
def draw(self,window):
self.move()
if self.Walking_index + 1 >= 33:
self.Walking_index = 0
if self.vel > 0:
window.blit(self.esright[self.Walking_index
self.Walking_index += 1
else:
window.blit(self.esleft[self.Walking_index
self.Walking_index += 1
def move(self):
if self.vel > 0:
if self.x + self.vel < self.path[1]:
self.x += self.vel
else:
self.vel = self.vel * -1
self.Walking_index = 0
else:
if self.x - self.vel > self.path[0]:
self.x += self.vel
else:
self.vel = self.vel * -1
self.Walking_index = 0
```
then I defined the class
```
black = (0,0,0)
enemys1 = enemy(550,436,50,50,300)
enemys = [enemys1]
```
and then on my main loop I made it so the enemy doesnt scroll with my screen left and right and up
```
runninggame = True
while runninggame:
clock.tick(FPS)
for event in pygame.event.get():
if event.type == pygame.QUIT:
runninggame = False
for enemy in enemys:
enemy.y += playerman.speed
```
```
then I drawed my enemy on the main loop the problem is when I move the enemy moves
```
for enemy in enemys:
enemy.draw(window)
My full code: its to long to fit in here
[script](https:
It's too long to fit in. This is my attempt to move it but its not working well any help is appreciated! this is the making my player move left and right attempt
What I have tried:
what I have tried is if I am scrolling left I said for enemys in enemying: enemy.x -= playerman.speed