pygame 2.0  VS  pygame 2.0.0 dev6
先说结论:
| 1
 | pip3 install -i https://pypi.tuna.tsinghua.edu.cn/simple pygame==2.0.0.dev6
 | 
声明
以下问题和解决方案仅适用于:
- 我的个人电脑:mbp2019 macOS 10.15.7
- python 3.8.10
 
问题
当我使用pygame 2.0制作最简单的弹球游戏时,电脑屏幕的显示略有抽风,弹球并不是预期的一种匀速直线运动,而是像下面这样:
| 12
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 
 | import sys
 import pygame
 
 pygame.init()
 screen = pygame.display.set_mode((600, 500))
 pygame.display.set_caption("移动矩形")
 
 color = 255, 255, 0
 pos_x = 300
 pos_y = 250
 vx = 1
 vy = 1
 
 while True:
 for event in pygame.event.get():
 if event.type == pygame.QUIT:
 sys.exit()
 screen.fill((0, 0, 200))
 
 pos_x += vx
 pos_y += vy
 
 if pos_x > 500 or pos_x < 0:
 vx = -vx
 if pos_y > 400 or pos_y < 0:
 vy = -vy
 pos = pos_x, pos_y, 100, 100
 pygame.draw.rect(screen, color, pos)
 
 pygame.display.update()
 
 
 | 
 
这不行啊!怎么能恢复正常呢?
解决
终于在众多的百度谷歌中,找到一个短小精悍的回答,解决方案是用pygame的一个开发版,我怕出现问题就原封不动的安装了答主的版本(加了个镜像):
| 1
 | pip3 install -i https://pypi.tuna.tsinghua.edu.cn/simple pygame==2.0.0.dev6
 | 
这下好了:
