Pygame FG (7) – Framerate speed 2

Spread the love

With this code we can make our frame rate go very faster using the Group class and blits.

The structure of the code

Changes in the update function

The images are updated all at once every 180 frames… to make them not go too fast. They are updated at once with the Group class, to save frame rate. Also, to clear the screen we do not color all of it, but just the rectangles occupied by the images of the three sprites with the function hide_sprites below:

The hide_sprites function

This will blit the rectangles to delete the previous images of the sprites, all at once

You can see I do not used blit, but blits, for more surfaces at once.

Alternative to hide_sprites (to refresh all the page)

If you want you can use screen.fil((0,0,0)) into the update method of sprite in alternative to screen.blits of the three Surface object that covers just the sprites… maybe you could lose some framerate, I am not so sure, I will check this in another post

The whole code