Stergios Papadop
Stergios Papadop

Reputation: 1

Why does screen = pygame.display.set_mode() can do screen.blit()?

I saw a piece of code like this one:

Screen = pygame.display.set_mode(...)`

Screen.blits(...)

My question is, how we should call the blits method from the variable screen. Is it because display is a class and screen becomes an object? However, if this is true then shouldn't we have to do instead screen = pygame.display()?

Upvotes: 0

Views: 131

Answers (1)

Kingsley
Kingsley

Reputation: 14916

Looking at the manual for pygame.display.set_mode(), you can see that it returns a Surface type object, so in effect it "constructs" a new object.

The manual for the PyGame Surface object lists both blit() and blits() member functions. This is why it's correct to say Screen.blit(...) as in your question code.

The code pygame.Display represents the name of a class, but it is not directly used like this.

Upvotes: 1

Related Questions