@Shroud228lol

Как работать с time.clock в pygame?

import pygame as pg
pg.init()
clock = pg.time.Clock()
run = True
while run:
    clock.tick(144)

Что в аргументе clock указывать надо? В моем коде это будет 144 fps, или надо показывать какую-то задержку?
  • Вопрос задан
  • 4636 просмотров
Решения вопроса 1
https://www.pygame.org/docs/ref/time.html#pygame.t...
tick()
update the clock
tick(framerate=0) -> milliseconds
This method should be called once per frame. It will compute how many milliseconds have passed since the previous call.

If you pass the optional framerate argument the function will delay to keep the game running slower than the given ticks per second. This can be used to help limit the runtime speed of a game. By calling Clock.tick(40) once per frame, the program will never run at more than 40 frames per second.

Note that this function uses SDL_Delay function which is not accurate on every platform, but does not use much CPU. Use tick_busy_loop if you want an accurate timer, and don't mind chewing CPU.
Ответ написан
Комментировать
Пригласить эксперта
Ответы на вопрос 1
IDzone-x
@IDzone-x
Костыли сила паттерны могила
Посмотри ету серию курса Гоши дударя
https://youtu.be/jBpUaD1dpYc
Ответ написан
Комментировать
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы