class Player: """ A class representing the player and all of its motions Parameters ---------- - pos: the starting position of the player """ def __init__(self, pos): self.rect = Rect(pos, (100, 10)) def update(self, game): """ updates the player on every frame before being drawn Parameters ---------- - game (Game): an instances of the Game class in order to access the game elements such as the current frame """ frame = cv.rotate(game.frame, cv.ROTATE_90_CLOCKWISE) faces = fr.face_locations(frame[:, ::-1]) if faces: top, right, bottom, left = faces[0] center = (right + left) / 2 self.rect.update(center - self.rect.width / 2, self.rect.top, self.rect.width, self.rect.height) def draw(self, screen): """ draws the player to the screen Parameters ---------- - screen (Surface): the screen to draw on """ pygame.draw.rect(screen, (255, 255, 255), self.rect)