1
class Rectangle:
    def __init__(self, image, alpha, origin, x, y):
        self.image = image
        if alpha: self.surface = pygame.image.load(image).convert_alpha()
        else: self.surface = pygame.image.load(image).convert()
        self.rectangle = self.surface.get_rect(origin = (x, y))

    def setpos(self, x, y):
        self.rectangle.x = x
        self.rectangle.y = y

    def place(self):
        screen.blit(self.surface, self.rectangle)

test = Rectangle('image.png', 1, 'midtop', 0, 0)

I want to input the origin, but it isn't working.

Rabbid76
  • 202,892
  • 27
  • 131
  • 174
Jibhong
  • 13
  • 4

1 Answers1

1

A pygame.Rect object has a lot of virtual attributes, however origin is not one of them. topleft or center, on the other hand, is:

self.rectangle = self.surface.get_rect(topleft = (x, y))
self.rectangle = self.surface.get_rect(center = (x, y))
Rabbid76
  • 202,892
  • 27
  • 131
  • 174