Tag Info

New answers tagged


If you really, truly, absolutely want access a sprite by index, you can do this: third_sprite = mygroup.sprites()[2] So your function would be: def getSpriteByPosition(position,group): return group.sprites()[position] Which throws IndexError if the index is not found. If you want to return None in that case, simply enclose the line with a try ...


Move along X axis only, test for colision, if true invert X movement. Repeat for Y.


The problem is in your pygame usage: you're re-creating the circle on every frame. Pygame works best if you create every image only once, on its own Surface (think of it as a virtual canvas), and then in each frame you blit that surface's image onto the screen (which is also a surface). Think of blit as an ultra-fast copy from surface to surface. Here's an ...


The official pygame docs say: http://www.pygame.org/docs/ref/surface.html#pygame.Surface.convert It is a good idea to convert all Surfaces before they are blitted many times. The converted Surface will have no pixel alphas. They will be stripped if the original had them So, as far as I can tell you should always .convert() them when you are going ...

Top 50 recent answers are included