sfqxx 发表于 2023-3-25 19:31:33

求助,为什么报错

本帖最后由 sfqxx 于 2023-3-26 09:10 编辑

这段代码,让图片可移动(其实就是抄了小甲鱼的代码),可是报错了
#18_1.py
import pygame
import sys
pygame.init()
size = width,height = 600,400
speed = [-2,1]
bg = (255,255,255)
screen = pygame.display.set.mode(size)
pygame.display.set_caption("我是sfqxx(鱼C账户)")

turtle = pygame.image.load("aru-1x-1_015.png")
position = turtle()
while True:
    for event in pygame.event.get():
      if event.type== pygame.QUIT:
            sys.exit()
    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)
报错信息:ModuleNotFoundError: No module named 'pygame'
应该是没有安装pygame模块,可我已经安装了
有图为证:
求大佬指教{:10_254:}
页: [1]
查看完整版本: 求助,为什么报错