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

게시물: 28 건, 현재: 1 / 1 쪽
[1]
번호 제       목 작성자 등록일 방문
29  ocr cv2 py jinsung 21.9.17 6
28  PIL to numpy jinsung 21.9.15 5
27  pygame.display.flip vs pygame.display.update jinsung 21.9.6 11
26  house.py jinsung 21.3.18 124
25  move_circle_j1.py jinsung 21.3.18 97
24  bounce_j1.py jinsung 21.3.18 90
23  모두의 파이썬 - 20일만에배우는 프로그래밍 기초 JMJS 20.1.8 266
22  python -m pip install -U pip JMJS 19.11.25 230
21  get =lambda i,m ... JMJS 19.11.13 238
20  2차원 리스트, 튜플 JMJS 19.11.13 251
19  [turtle]def polygon3(n,c,d) JMJS 19.11.11 228
18  [turtle]def polygon2(n,a) JMJS 19.11.11 234
17  def factorial(n) JMJS 19.11.11 217
16  def sum_func(n) JMJS 19.11.11 260
15  def hello() fun1(a) fun2(a,b) JMJS 19.11.11 249
14  while sum JMJS 19.11.11 210
13  random calculation JMJS 19.11.11 222
12  turtle random JMJS 19.11.11 226
11  import time time.time JMJS 19.11.11 236
10  turtle begin_fill end_fill JMJS 19.11.11 214
9  if else JMJS 19.11.11 219
8  input JMJS 19.11.11 228
7  list JMJS 19.11.11 241
6  turtle triangle JMJS 19.11.11 227
5  for range JMJS 19.11.11 213
4  모듈 사용하기 JMJS 19.11.11 229
3  import 파이썬 모듈 가져다 쓰기 JMJS 19.11.11 245
1  print 줄바꿈 JMJS 19.11.11 275
[1]