1

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).

Brambor
  • 604
  • 1
  • 8
  • 25
  • Are you bound to the Clock.tick method? Common way of executing a script in one second's interval would be the `import time` module together with `while true` (for an endless loop) and `time.sleep(1)` – offeltoffel Sep 11 '17 at 11:21
  • @offeltoffel No, I'm not bound to `Clock.tick()`, anythng will do (pygame and preinstalled modules are prefered). I think that `time.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 have `time.sleep(t)` and then calculate t, but that's basicly what `Clock.tick()` does. – Brambor Sep 11 '17 at 13:48

0 Answers0