0

There seems to be some sort of cap for time.sleep() that is stopping my "pong" game from increasing speed appropriately.

game_is_on = True
while game_is_on:
    time.sleep(ball.move_speed)
    screen.update()
    ball.move()

where move_speed is reduced by 20% after every such-and-such occurrence.

I've tested it by removing ball.move_speed and instead used 0.1, then 0.01, both of which worked, but when I try 0.001 or lower, it doesn't get any faster.

Kyle
  • 13
  • 3
  • Which operating system? On linux I think the resolution is 1 millisecond. – tdelaney Aug 05 '22 at 01:00
  • Does it work outside PyCharm? It might be an issue with the way the PyCharm console buffers output. – Barmar Aug 05 '22 at 01:02
  • 1
    Some good information [here](https://stackoverflow.com/questions/1133857/how-accurate-is-pythons-time-sleep) about sub-second `sleep()`. – sj95126 Aug 05 '22 at 01:34
  • Sorry I'm noob and don't know how to respond to individual comments. I'm on windows. I haven't actually tried it outside of PyCharm, I'll look into it! – Kyle Aug 05 '22 at 01:44
  • To respond to an individual use for instance @tdelaney. – tdelaney Aug 05 '22 at 02:54
  • Can you edit your question to include a [mcve], then it will be possible to assist you. Which libraries are you using? – import random Aug 05 '22 at 03:30

0 Answers0