黑与白的灰 发表于 2021-3-24 16:57:53

pygame全屏后取消全屏后,为啥窗口会显示在左上角,窗口标题也卡出屏幕了

我这个全屏后取消全屏后,为啥窗口会显示在左上角,窗口标题也卡出屏幕了(帖子里怎么传图片呀o(╥﹏╥)o)
import pygame
import sys
import os
from pygame.locals import *

#   初始化Pygame
pygame.init()

#   设置帧率
clock = pygame.time.Clock()

size = width, height = 500, 600
#   每次移动的位置
speed =
bg = (255, 255, 255)
data = os.path.dirname(os.path.realpath(__file__))
data_image = os.path.join(data, "image\优领108.png")

#   创建指定大小的窗口
screen = pygame.display.set_mode(size)
#   设置窗口标题
pygame.display.set_caption("(ノ◑ ◑)ノ(。•́︿•̀。)")

#   加载图片
turtle = pygame.image.load(data_image)
#   获取图片矩形位置
position = turtle.get_rect()

#   全屏参数
fullscreen = False

while True:
    #   获取用户当前动作的事件列表
    for event in pygame.event.get():
      if event.type == pygame.QUIT:
            sys.exit()
      #   图片随键盘移动
      if event.type == KEYDOWN:
            #   全屏(F11)
            if event.key == K_F11:
                fullscreen = not fullscreen
                if fullscreen:
                  #   display.list_modes() 获取屏幕最大的分辨率
                  screen = pygame.display.set_mode(pygame.display.list_modes(), FULLSCREEN | HWSURFACE)
                else:
                  screen = pygame.display.set_mode(size)

    #   填充背景
    screen.fill(bg)
    #   更新图像
    screen.blit(turtle, position)
    #   更新界面
    pygame.display.flip()
    #   延迟10毫秒
    # pygame.time.delay(0)
    clock.tick(200)


小伤口 发表于 2021-3-25 09:49:32

{:10_254:}好像你发的代码也不能实现全屏呀

lixiangyv 发表于 2021-3-28 19:57:40

这个可能是 pygame 的 bug 吧
页: [1]
查看完整版本: pygame全屏后取消全屏后,为啥窗口会显示在左上角,窗口标题也卡出屏幕了