-->

Welcome to our Coding with python Page!!! hier you find various code with PHP, Python, AI, Cyber, etc ... Electricity, Energy, Nuclear Power

Tuesday 3 July 2018

Python | The start of a game in pygame, blitting images to the screen

The small bit of code below blits and image to the screen within a class. I call this 4 times to display the image 4 times, each image has a different y coordinate and doesn't need different x but when they are blitted they make the code MUCH slower. I know it is the blitting as well due to the fact that if i just draw rects instead, the program moves smoothly.

tableTex = pygame.transform.scale(pygame.image.load('./Sources/Table.png'), (270, 240))

    def display(self):
        if not self.occupied:
            screen.blit(tableTex, (self.x, self.y))
        else:
            pygame.draw.rect(screen, (127, 0, 0), self.rect, 0)
A link to the full code can be found here if needed. I just want to know if there is any reason this is so slow and if there are any other methods I could use that are faster?
Thanks

No comments:

Post a Comment

Thanks for your comments

Rank

seo