My code simplified:
Clock.tick(UPS): #updates per second
game.update()
for frame in range(FPU) #frames per update
game.draw(frame)
What it should do is that every second there should be a number of updates equal to UPS value. After each update, the number of frames drawn will be equal to FPU. It does mean that FPS is UPS*FPU.
My question is how to set that to be smooth, fluent. Smoothness is the key question of this Question.
I need to have each game.draw() to be equally distant (in time) from each other.
There is Clock = pygame.clock then Clock.tick(UPS*FPU) doesn't work since update happens as many times as draw * FPU.
Should I use clock inside clock? Would that work? (I tried but I'm not sure about the results - whether it would work for all extremes.)
Clock1.tick(UPS):
game.update()
Clock2.tick(FPU):
game.draw(frame)
or maybe just inside clock? would that work?
game.update()
Clock.tick(UPS*FPU)
game.draw()
There is pygame.Clock of which I'm considering using tick.tick_busy_loop() but that is matter of experimentation - not matter of this Question.
And if you want to you can check out in which project will I be using this. (specifically there).
import timemodule together withwhile true(for an endless loop) andtime.sleep(1)Clock.tick(), anythng will do (pygame and preinstalled modules are prefered). I think thattime.sleep(1)will make the programm wait for one second, but let's say that it takes my program 500 miliseconds to update and draw 60 times, so it wouldn't be "frames per second" but rather "frames per second and a half". That said I could havetime.sleep(t)and then calculate t, but that's basicly whatClock.tick()does.