大聪胡 2022-05-31 19:07 采纳率: 100%
浏览 37
已结题

【代码报错】Python

谁能帮我看一下这个代码哪里错了,我老报错
from Walimaker import *
setup(1024,512)

bg_far1=Character('./Background/scroll_bg_far.png')
bg_far2=Character('./Background/scroll_bg_far.png')
bg_far2.x=2048
hills1=Character('./Background/hills-scroll.png')
hills2=Character('./Background/hills-scroll.png')
hills2.x=2048
hills1.y=-50
hills2.y=-50
bg_grass1=Character('./Background/bg_grass.png')
bg_grass2=Character('./Background/bg_grass.png')
bg_grass2.x=2048

horse_run_img=['./Sprite/Horse/horse-run-00.png',
'./Sprite/Horse Ice/ice-horse-run-01.png',
'./Sprite/Horse Ice/ice-horse-run-02.png',
'./Sprite/Horse Ice/ice-horse-run-03.png',
'./Sprite/Horse Ice/ice-horse-run-04.png',
'./Sprite/Horse Ice/ice-horse-run-05.png',
'./Sprite/Horse Ice/ice-horse-run-06.png',]
horse_jump_img=['./Sprite/Horse/horse-run-00.png',
'./Sprite/Horse Ice/ice-horse-jump-01.png',
'./Sprite/Horse Ice/ice-horse-jump-02.png',
'./Sprite/Horse Ice/ice-horse-jump-03.png',
'./Sprite/Horse Ice/ice-horse-jump-04.png',
'./Sprite/Horse Ice/ice-horse-jump-05.png',
'./Sprite/Horse Ice/ice-horse-jump-06.png',]
horse_img={'run':horse_run_img,'jump':horse_jump_img}

horse=Character(horse_img)
horse.state='run'

horse.play_anim()#播放图片
#horse.dt=0.005极快的速度 更改马的速度
horse.set_dt('run',0.01)
horse.set_dt('jump',0.01)
horse.goto(-400,-110)#更改位置x,y
horse.ay=-0.9
#金币 Sprite 动画精灵 Sheet 清单
coin_img=SpriteSheet('./Sprite/coin_gold.png',8,1)
coin1=Character(coin_img)
coin1.play_anim()
coin1.scale(3)
coin1.x=1000
coin2=Character(coin_img)
coin2.play_anim()
coin2.scale(3)
coin2.x=2000
#计分
text=TextBox(100)#字体大小
text.print('吃屎量:0')
text.goto(0,150)
score=0#计分

#蝙蝠
bat_img=SpriteSheet('./Sprite/bat.png',4,4)
bat1.play_anim()
bat2=Character(bat_img[13:])
bat2.play_anim()
bat1.scale(3)
bat2.scale(3)
bat1.x=1500
bat2.x=3000

while True:
bg_far1.backward(10)
bg_far2.backward(10)
hills1.backward(10)
hills2.backward(10)
bg_grass1.backward(10)
bg_grass2.backward(10)
if bg_far1.x<-2030:
bg_far1.x=bg_far2.x+2040
if bg_far2.x<-2030:
bg_far2.x=bg_far1.x+2040
if hills1.x<-2030:
hills1.x=hills2.x+2040
if hills2.x<-2030:
hills2.x=hills1.x+2040
if bg_grass1.x<-2030:
bg_grass1.x=bg_grass2.x+2040
if bg_grass2.x<-2030:
bg_grass2.x=bg_grass1.x+2040
#小马的跳跃
horse.vy+=horse.ay
if horse.collide (bg_grass1) or horse.collide (bg_grass2):
horse.vy=max(0,horse.vy)
horse.state='run'
if key_pressed(K_SPACE):
horse.state='jump'
horse.vy=15

horse.y+=horse.vy
#金币
coin1.backward(10)
coin2.backward(10)
if coin1.x<1000:
    coin1.x=1000
    horse.play_snd('./snd/金币.wav')
if coin2.x<1000:
    coin2.x<1000
    ('./snd/金币.wav')
if horse.collide(coin1):
    coin1.x=1500
    score +=1
    text.print(f'吃屎量:{score}')
if horse.collide(coin2):
    coin2.x=1500
    score +=1
    text.print(f'吃屎量:{score}')

bat1.backward(10)
bat2.backward(10)

if bat1.x<-1500:
    bat1.x=-1500
if bat2.x<-1500:
    bat2.x=-1500
if horse.collide(bat1) or horse.collide(bat2):
    text.print('noooooooooooooo')
    while True:
        if key_pressed(K_r):
            bat1.x=1500
            bat2.x=2500
            score=0
            text.print(f'吃屎量:{score}')
            break
        update()


update()
  • 写回答

2条回答 默认 最新

  • 我是肖某人 2022-06-05 15:47
    关注

    你这个用的是Walimaker数据库,下载不到,我只能简单改一下,因为语法很奇怪

    from Walimaker import *
    setup(1024,512)
    
    bg_far1=Character('./Background/scroll_bg_far.png')
    bg_far2=Character('./Background/scroll_bg_far.png')
    bg_far2.x=2048
    hills1=Character('./Background/hills-scroll.png')
    hills2=Character('./Background/hills-scroll.png')
    hills2.x=2048
    hills1.y=-50
    hills2.y=-50
    bg_grass1=Character('./Background/bg_grass.png')
    bg_grass2=Character('./Background/bg_grass.png')
    bg_grass2.x=2048
    
    horse_run_img=['./Sprite/Horse/horse-run-00.png',
               './Sprite/Horse Ice/ice-horse-run-01.png',
               './Sprite/Horse Ice/ice-horse-run-02.png',
               './Sprite/Horse Ice/ice-horse-run-03.png',
               './Sprite/Horse Ice/ice-horse-run-04.png',
               './Sprite/Horse Ice/ice-horse-run-05.png',
               './Sprite/Horse Ice/ice-horse-run-06.png',]
    horse_jump_img=['./Sprite/Horse/horse-run-00.png',
               './Sprite/Horse Ice/ice-horse-jump-01.png',
               './Sprite/Horse Ice/ice-horse-jump-02.png',
               './Sprite/Horse Ice/ice-horse-jump-03.png',
               './Sprite/Horse Ice/ice-horse-jump-04.png',
               './Sprite/Horse Ice/ice-horse-jump-05.png',
               './Sprite/Horse Ice/ice-horse-jump-06.png',]
    horse_img={'run':horse_run_img,'jump':horse_jump_img}
    
    horse=Character(horse_img)
    horse.state='run'
    
    horse.play_anim()#播放图片
    #horse.dt=0.005极快的速度 更改马的速度
    horse.set_dt('run',0.01)
    horse.set_dt('jump',0.01)
    horse.goto(-400,-110)#更改位置x,y
    horse.vy=0
    horse.ay=-0.9
    #金币 Sprite 动画精灵  Sheet 清单
    coin_img=SpriteSheet('./Sprite/coin_gold.png',8,1)
    coin1=Character(coin_img)
    coin1.play_anim()
    coin1.scale(3)
    coin1.x=1000
    coin2=Character(coin_img)
    coin2.play_anim()
    coin2.scale(3)
    coin2.x=2000
    #计分
    text=TextBox(100)#字体大小
    text.print('吃屎量:0')
    text.goto(0,150)
    score=0#计分
    
    #蝙蝠
    bat_img=SpriteSheet('./Sprite/bat.png',4,4)
    bat1=Character(bat_img[13:])
    bat1.play_anim()
    bat2=Character(bat_img[13:])
    bat2.play_anim()
    bat1.scale(3)
    bat2.scale(3)
    bat1.x=1500
    bat2.x=3000
    
    
    
    while True:
        bg_far1.backward(10)
        bg_far2.backward(10)
        hills1.backward(10)
        hills2.backward(10)
        bg_grass1.backward(10)
        bg_grass2.backward(10)
        if bg_far1.x<-2030:
            bg_far1.x=bg_far2.x+2040
        if bg_far2.x<-2030:
            bg_far2.x=bg_far1.x+2040
        if hills1.x<-2030:
            hills1.x=hills2.x+2040
        if hills2.x<-2030:
            hills2.x=hills1.x+2040
        if bg_grass1.x<-2030:
            bg_grass1.x=bg_grass2.x+2040
        if bg_grass2.x<-2030:
            bg_grass2.x=bg_grass1.x+2040
        #小马的跳跃
        horse.vy+=horse.ay
        if horse.collide (bg_grass1) or horse.collide (bg_grass2):
            horse.vy=max(0,horse.vy)
            horse.state='run'
            if key_pressed(K_SPACE):
                horse.state='jump'
                horse.vy=15
        
        horse.y+=horse.vy
        #金币
        coin1.backward(10)
        coin2.backward(10)
        if coin1.x<1000:
            coin1.x=1000
            horse.play_snd('./snd/金币.wav')
        if coin2.x<1000:
            coin2.x<1000
            ('./snd/金币.wav')
        if horse.collide(coin1):
            coin1.x=1500
            score +=1
            text.print(f'吃屎量:{score}')
        if horse.collide(coin2):
            coin2.x=1500
            score +=1
            text.print(f'吃屎量:{score}')
    
        bat1.backward(10)
        bat2.backward(10)
    
        if bat1.x<-1500:
            bat1.x=-1500
        if bat2.x<-1500:
            bat2.x=-1500
        if horse.collide(bat1) or horse.collide(bat2):
            text.print('noooooooooooooo')
            while True:
                if key_pressed(K_r):
                    bat1.x=1500
                    bat2.x=2500
                    score=0
                    text.print(f'吃屎量:{score}')
                    break
                update()
    
        
        update()
    
    
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

问题事件

  • 系统已结题 6月15日
  • 已采纳回答 6月7日
  • 创建了问题 5月31日

悬赏问题

  • ¥15 求给定范围的全体素数p的(p-2)的连乘积
  • ¥15 VFP如何使用阿里TTS实现文字转语音?
  • ¥100 需要跳转番茄畅听app的adb命令
  • ¥50 寻找一位有逆向游戏盾sdk 应用程序经验的技术
  • ¥15 请问有用MZmine处理 “Waters SYNAPT G2-Si QTOF质谱仪在MSE模式下采集的非靶向数据” 的分析教程吗
  • ¥50 opencv4nodejs 如何安装
  • ¥15 adb push异常 adb: error: 1409-byte write failed: Invalid argument
  • ¥15 nginx反向代理获取ip,java获取真实ip
  • ¥15 eda:门禁系统设计
  • ¥50 如何使用js去调用vscode-js-debugger的方法去调试网页