0
self.dir = random.randint(1,4)
amount = 20 
if self.dir == 1: 
    self.direction = 'forwards'
    dist = 0
    while dist < amount: 
        self.rect.y += 1
        dist += 1

This is what I have right now. However, the monster is still just jumping pixels instead of going one pixel at a time. I think this is because the move function for the monster is being called in the main function, which is set to clock.tick(60). Does anyone know what I could do to fix this?

Fruchtzwerg
  • 10,999
  • 12
  • 40
  • 49
sy89
  • 195
  • 2
  • 14
  • 3
    Could you provide a [minimal, runnable example](https://stackoverflow.com/help/mcve)? It looks like you need to remove the `while dist < amount:` loop and just move the object a few pixels (the desired speed) every frame. – skrx Nov 25 '17 at 19:06
  • 1
    when you run `while dist < amount: self.rect.y += 1` then it changes value `self.rect.y` but it doesn't return to mainloop to redraw moster after every pixel. It does the same as `self.rect.y += amount` – furas Nov 25 '17 at 19:43
  • The reason I have the while loop is because I only want the monster to change direction after it has gone a good amount of distance. I don't want it to go a few pixels and then change direction because the move function was called again – sy89 Nov 26 '17 at 01:52

0 Answers0