gamelib.py
def loop(self, fps: int=30) -> bool:
        """
        When used in a `while` loop, the body will be executed `fps` times per second.

        Returns:
            `True` if the game window is still open, `False` otherwise.

        Example:
            ```
            while gamelib.loop(fps=30):
                # this is executed 30 times per second
                for event in gamelib.get_events():
                    if event.type == gamelib.EventType.KeyPress and event.key == 'q':
                        return
            ```
        """

        frame_duration = 1.0 / fps
        a = _GameThread._last_loop_time
        b = time()
        if a:
            sleep(max(0, frame_duration - (b - a)))
        _GameThread._last_loop_time = time()
        return self.is_alive()

        When used in a `while` loop, the body will be executed `fps` times per second.

        Returns:
            `True` if the game window is still open, `False` otherwise.

        Example:
            ```
            while gamelib.loop(fps=30):
                # this is executed 30 times per second
                for event in gamelib.get_events():
                    if event.type == gamelib.EventType.KeyPress and event.key == 'q':
                        return
            ```
        
When used in a `while` loop, the body will be executed `fps` times per second.
When used in a ` while ` loop the body will be executed ` fps ` times per second .
def loop(self, fps: int=30) -> bool:
        frame_duration = 1.0 / fps
        a = _GameThread._last_loop_time
        b = time()
        if a:
            sleep(max(0, frame_duration - (b - a)))
        _GameThread._last_loop_time = time()
        return self.is_alive()
def loop ( self , fps : int = 30 ) -> bool : frame_duration = 1.0 / fps a = _GameThread . _last_loop_time b = time ( ) if a : sleep ( max ( 0 , frame_duration - ( b - a ) ) ) _GameThread . _last_loop_time = time ( ) return self . is_alive ( )
When used in a `while` loop, the body will be executed `fps` times per second.
When used in a ` while ` loop the body will be executed ` fps ` times per second .
"""
        When used in a `while` loop, the body will be executed `fps` times per second.

        Returns:
            `True` if the game window is still open, `False` otherwise.

        Example:
            ```
            while gamelib.loop(fps=30):
                # this is executed 30 times per second
                for event in gamelib.get_events():
                    if event.type == gamelib.EventType.KeyPress and event.key == 'q':
                        return
            ```
        """
`True` if the game window is still open, `False` otherwise.
` True ` if the game window is still open ` False ` otherwise .
self
fps
int
examples
```
while gamelib.loop(fps=30):
this is executed 30 times per second
for event in gamelib.get_events():
if event.type == gamelib.EventType.KeyPress and event.key == 'q':
return
```
` ` ` while gamelib . loop ( fps = 30 ) : this is executed 30 times per second for event in gamelib . get_events () : if event . type == gamelib . EventType . KeyPress and event . key == ' q ' : return ` ` `