1
1
12LiCaNtRoP122020-08-22 12:44:00
pygame
12LiCaNtRoP12, 2020-08-22 12:44:00

Should it be like this?

I started learning to develop games on pygame, but suddenly I noticed that even the simplest things make the processor work much harder than with much larger games, and if there are more than 6 objects on the screen, then lags already begin. The question is, is pygame itself so unproductive, or is it more likely due to bad code? I study from one book and do almost everything like from there, the only thing is changing some methods for solving the same problem and using different images. Also, I'm using large images that take up quite such a large area of ​​the screen, could there be a drawdown due to this? If you need more, I can throw off the folder in which everything that is used in the game is connected. And another question, is it ok to use .png images instead of .bmp? It's just that with the .bmp format, the background cannot be erased from the image, but with .

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
da da, 2020-08-22
@IIggoorrII

before the game loop write:
clock=pygame.time.Clock()
and inside the game loop write:
clock.tick(30) #clock.tick(<number of cycle rounds per second>)

S
shurshur, 2020-08-22
@shurshur

As they write in these your Internets, PyGame works as a wrapper around SDL and itself does not know how to hardware accelerate graphics. Source: https://gamedev.stackexchange.com/questions/73328/... (and links to detailed examples there). Another link with pictures and code examples https://stackabuse.com/advanced-opengl-in-python-w...
Yes, not all image formats support transparent background and alpha channel. bmp is essentially just an array of the RGB colors of each point, there is no transparency in RGB like there is in RGBA.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question