What is the difference between screen.blit(player, (xpos, ypos)) and display.flip() in pygame?

Question:

Both appear to update either the entire screen or just a section of the screen, but which does what and how?

Asked By: RossC

||

Answers:

blit() doesn’t update screen – it draws image in buffer.

update() and flip() sends buffer to video card which displays it on monitor.

If you have code with blit() but without update() or flip() then it will display nothing.


flip() sends all buffer to video card. Probably it can use optimized method to do it fast.

update() can get list with Rect() and sends only some part of buffer so it could be faster. But you have to know which parts you what to replace. Sometimes it is hard to correctly choose which areas to update.

See doc: update(), flip()


enter image description here

Answered By: furas
Categories: questions Tags: , , , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.