[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] Surface Sprite Rect -> HELP



Hi there,

A surface is like a container for an image. You would blit a surface
to see an image (dont forget to update).

A sprite can be an object like an enemyship or any other object.

A rect is a box that you can create and fill with a color and blit the
surface to see an image. You can also get parts of other images with
rects, i believe.

Here is some code, if it helps you understand better than my writing.

class EnemyShip(pygame.sprite.Sprite):


def __init__(self, initial_position,hits_to_take): pygame.sprite.Sprite.__init__(self) self.rect = play.cache["enemy.png"].get_rect()


Good luck with tetris and dont be shy to ask any questions.

-spot

On 11/20/06, Nicolas Bischof <nicolas.bischof@xxxxxxxxx> wrote:
Greetings!
i´m making my first game, it will be a Tetris.
But i sill don´t understand when to use Surfaces,  Sprites and Rects,
and their intended propose and their best utilization scenario.
could someone explain the relation of Surface, Sprite and Rect, their
ideal intended propose?