鱼C论坛

 找回密码
 立即注册
查看: 451|回复: 1

p79,打不开加载的图片怎么办?、在线等,急急急!!!!

[复制链接]
发表于 2018-9-23 12:35:18 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能^_^

您需要 登录 才可以下载或查看,没有账号?立即注册

x
提示我打不开图片
Python 3.7.0 (v3.7.0:1bf9cc5093, Jun 27 2018, 04:59:51) [MSC v.1914 64 bit (AMD64)] on win32
Type "copyright", "credits" or "license()" for more information.
>>>
============= RESTART: C:\Users\Administrator\python\小甲鱼移动游戏.py =============
pygame 1.9.4
Hello from the pygame community. https://www.pygame.org/contribute.html
Traceback (most recent call last):
  File "C:\Users\Administrator\python\小甲鱼移动游戏.py", line 18, in <module>
    turtle=pygame.image.load(os.path.join(r'C:\User\Administrator','turtle.gif'))
pygame.error: Couldn't open C:\User\Administrator\turtle.gif
>>>
=============================== RESTART: Shell ===============================
>>>
下面是我代码
mport pygame
import sys
import os
from pygame.locals import *
#初始化pygame
pygame.init()

size=width,hight=600,400

speed=[-2,1]
bg=(255,255,255)#RGB
fullscreen=False
#创建指定大小的窗口
screen=pygame.display.set_mode(size)
#设置窗口标题
pygame.display.set_caption("初次见面,请多关照!")
#加载图片
turtle=pygame.image.load(os.path.join(r'C:\User\Administrator','turtle.gif'))
#获得图像的矩形位置
position=turtle.get_rect()
I_head=turtle
r_head=pygame.transform.flip(turtle,True,False)
while True:
    for event in pygame.event.get():
        if event.type==pygame.QUIT:
            sys.exit()
   
        if event.type==KEYDOWN:
            if event.key==K_LEFT:
                turtle=I_head
                speed=[-1,0]
            if event.key==K_RIGHT:
                turtle=r_head
                speed=[1,0]
            if event.key==K_UP:
                speed=[0,-1]
            if event.key==K_DOWM:
                speed=[0,1]
            #全屏
            if event.key==K_F11:
                fullscreen =not fullcreen
                if fullscreen:
                    screen=pygame.display.set_mode((1024,768),FULLSCREEN|HWSURFACE)
                else:
                    screen=pygame.display.set_mode(size)
            
            

    #移动图像
    position=position.move(speed)

    if position.left<0 or position.right>width:
        #图像翻转
        turtle=pygame.tiansform.flip(turtle,True,False)
        #反方向移动
        speed[0]=-speed[0]
    if position.top<0 or position.bottom>height:
        speed[1]=-speed[1]

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

想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

发表于 2018-9-23 13:09:59 | 显示全部楼层
路径不对吧
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2024-4-25 15:10

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表