LogIn E-mail
설계이야기
pygame.display.flip vs pygame.display.update
# 27 jinsung    70.1.1 09:00



The main difference between pygame.display.flip and pygame.display.update is, that

    display.flip() will update the contents of the entire display
    display.update() allows to update a portion of the screen, instead of the entire area of the screen. Passing no arguments, updates the entire display

To tell PyGame which portions of the screen it should update (i.e. draw on your monitor) you can pass a single pygame.Rect object, or a sequence of them to the display.update() function. A Rect in PyGame stores a width and a height as well as a x- and y-coordinate for the position.

PyGame's built-in dawning functions and the .blit() method for instance return a Rect, so you can simply pass it to the display.update() function in order to update only the "new" drawn area.

Due to the fact that display.update() only updates certain portions of the whole screen in comparison to display.flip(), display.update() is faster in most cases.



I wonder why they didn't just make it update() with optional arguments. –
Robo Robok
Sep 7 '20 at 16:16
Because flip might actually work faster due to the use of OpenGL/hardware acceleration. For example, for a simple loop with 3 sprites on a MacBook Pro 2019, pygame's flip gives "insane" 6 FPS compared to 3 FPS for an update of rect regions. –
Maximus
Sep 27 '20 at 4:08

게시물: 33 건, 현재: 1 / 1 쪽
[1]
번호 제       목 작성자 등록일 방문
34  sys.argv jinsung 22.4.1 39
33  args kwargs jinsung 22.4.1 40
32  set 집합 jinsung 22.3.24 40
31  getopt - 명열 줄 옵션용 c 스타일 구문 JMJS 22.4.1 72
30  tuple 은 수정 못함 jinsung 21.11.6 108
29  ocr cv2 py jinsung 21.9.17 147
28  PIL to numpy jinsung 21.9.15 140
27  pygame.display.flip vs pygame.display.update jinsung 21.9.6 174
26  house.py jinsung 21.3.18 290
25  move_circle_j1.py jinsung 21.3.18 239
24  bounce_j1.py jinsung 22.2.15 234
23  모두의 파이썬 - 20일만에배우는 프로그래밍 기초 JMJS 20.1.8 416
22  python -m pip install -U pip , matplotlib arcade ... jinsung 22.4.15 343
21  get =lambda i,m ... JMJS 19.11.13 340
20  2차원 리스트, 튜플 jinsung 21.11.6 358
19  [turtle]def polygon3(n,c,d) JMJS 19.11.11 338
18  [turtle]def polygon2(n,a) JMJS 19.11.11 333
17  def factorial(n) JMJS 19.11.11 303
16  def sum_func(n) JMJS 19.11.11 350
15  def hello() fun1(a) fun2(a,b) JMJS 19.11.11 333
14  while sum JMJS 19.11.11 294
13  random calculation JMJS 19.11.11 309
12  turtle random JMJS 19.11.11 313
11  import time time.time JMJS 19.11.11 314
10  turtle begin_fill end_fill JMJS 19.11.11 307
9  if else JMJS 19.11.11 298
8  input JMJS 19.11.11 310
7  list JMJS 19.11.11 322
6  turtle triangle JMJS 19.11.11 309
5  for range JMJS 19.11.11 304
4  모듈 사용하기 JMJS 19.11.11 312
3  import 파이썬 모듈 가져다 쓰기 JMJS 19.11.11 331
1  print 줄바꿈 JMJS 19.11.11 370
[1]