1class Player(pg.sprite.Sprite):
2
3 def __init__(self, pos, image):
4 super().__init__()
5 self.image = image
6 self.rect = self.image.get_rect(center=pos)
7
8
9player1 = Player((100, 300), IMAGE1)
10player2 = Player((300, 300), IMAGE2)
1import pygame as pg
2
3
4pg.init()
5# The screen/display has to be initialized before you can load an image.
6screen = pg.display.set_mode((640, 480))
7
8IMAGE = pg.image.load('an_image.png').convert_alpha()
9
10
11class Player(pg.sprite.Sprite):
12
13 def __init__(self, pos):
14 super().__init__()
15 self.image = IMAGE
16 self.rect = self.image.get_rect(center=pos)