pygame 新人求助:如下代码在按下F11后显示一个缩在左上角不能移动的窗口!!求解决
本帖最后由 mr.wyu 于 2021-9-4 09:25 编辑如下代码:在按下F11后显示一个缩在左上角不能移动的窗口,而且没有边框 没有控制按钮!!!!正常情况的话,按下F11 会在屏幕中间 出现一个窗口游戏端!!!import pygame
import sys
from pygame.locals import *
pygame.init()
size = width, height = 600, 600
speed = [-2, 1]
bg = (255, 255, 255)
clock = pygame.time.Clock()
screen = pygame.display.set_mode(size)
pygame.display.set_caption('乱跑的小火箭')
turtle = pygame.image.load('images/ship.bmp')
position = turtle.get_rect()
fullscreen = False
while True:
for event in pygame.event.get():
if event.type == QUIT:
sys.exit()
if event.type == KEYDOWN:
if event.key == K_q:
sys.exit()
if event.key == K_F11:
fullscreen = not fullscreen
if fullscreen:
screen = pygame.display.set_mode(pygame.display.list_modes(), FULLSCREEN)
else:
screen = pygame.display.set_mode(size)
position = position.move(speed)
if position.left < 0 or position.right > width:
turtle = pygame.transform.flip(turtle, True, False)
speed = -speed
if position.top < 0 or position.bottom > height:
speed = -speed
screen.fill(bg)
screen.blit(turtle, position)
pygame.display.flip()
pygame.time.delay(10)
你把24到27行的代码往左缩进一下试试 小伤口 发表于 2021-9-4 11:00
你把24到27行的代码往左缩进一下试试
试过了。。没用哎!!!你能复制下代码 运行帮我试试嘛 看看是代码原因还是其他原因
mr.wyu 发表于 2021-9-4 14:08
试过了。。没用哎!!!你能复制下代码 运行帮我试试嘛 看看是代码原因还是其他原因
电脑不在身边抱歉 自己已经找到原因了,跟代码没有关系!是因为pygame的安装问题,卸载了之后,在重新安装了pygame后问题消失
页:
[1]