Reputation: 311
I have created Pygame, which has objects (balls) which randomly move around the screen and the mouse control a character which the user moves around to avoid the other objects. but the random ball that move around the screen have slow refresh rate (you can see them flashing while moving).
I don't know which part of the code is to blame, the objects that move around are loaded here:
ballpic = pygame.image.load('ball.png').convert_alpha()
I don't which other part of the game is to blame so I can include in question, so I have created a pastebin http://pastebin.com/H6KkTvZU which has the game code (short game).
Thank you
Upvotes: 0
Views: 2271
Reputation: 2270
The Pygame newbie tutorial has some other useful advice, particularly how to use "Dirty rect animation" if your frame-rate is still too low.
Upvotes: 2
Reputation: 40894
You call display.update()
on every iteration of for i in range(enemies)
loop.
Try doing it once per frame, after you have blit
ted all the sprites.
Even better, learn how to use display.flip()
properly; it's faster if you update large portions of the screen.
Upvotes: 2