获得图片矩形对象 -> Rect(x, y, width, height)
# 默认情况下左上角的坐标是 (0, 0)
rect = image.get_rect(centerx=x, centery=...y)
# 在原位置基础上,移动指定的偏移量 (x, y 增加)
rect.move_ip(num1, num2)
# 判断两个矩形是否相交,相交返回True,否则返回False
flag = pygame.Rect.colliderect...键盘按下事件
if event.type == pygame.KEYDOWN:
# 判断用户按下的键是否是a键
if event.key == pygame.K_a...获得当前键盘所有按键的状态(按下,没有按下),返回bool元组
pressed_keys = pygame.key.get_pressed()
(0, 0, 0, 0, 1, 0, 0, 0, 0)...textrect = textobj.get_rect(centerx=300, centery=300)
# 在指定位置绘制指定文字对象
window.blit(textobj, textrect