Lv.1
我说我在js病院是在蹭空调你信吗
签名:沉迷于编程,等待变成高手
在 如何在Python里搞舞台区 中回复
你可以试试pgzrun
import pgzrun
bg = Actor('图片.png')
def draw():
bg.draw()
pgzrun.go()2023-08-03T17:25:29 点赞:0
在 如何在Python里搞舞台区 中回复
import pgzrun
bg = Actor("青青平原.gif")#要加上后缀名
codemao = Actor("马里喵1.gif",[114,514])#[]内为角色初始坐标
def draw():
bg.draw()
codemao.draw()
def move_x(num):
codemao.x += num
move_x(114)
pgzrun.go()
2023-08-14T10:23:19 点赞:0
在 如何在Python里搞舞台区 中回复
importpgzrun,time,random#导入库 wt=time.time() die=0 score=0 WIDTH=800 HEIGHT=800 #一系列变量 bg=Actor("bg.gif") holes=[] foriinrange(6): hole=Actor("hole.png",[120+i%3*250,300+i//3*250+i%3*40]) hole.wait=random.randint(2,10) holes.append(hole) hammer=Actor("hammer1.png") lost=Actor("失败.png",[-114514,400]) #角色制作 defdraw(): globalscore bg.draw() forholeinholes: hole.draw() hammer.draw() lost.draw() screen.draw.text('分数:'+str(score),[0,0],fontsize=50,color="red") #角色显示 defupdate():#重复执行 globalwt,die,score#全局变量 ifdie==1:#侦测喵 lost.x=400 music.play_once("溜走.mp3") die=2#确保只执行一次 iftime.time()-wt>=1anddie==0:#没有死且每次间隔1秒 forholeinholes:#遍历 ifhole.wait==0:#到达交换时间 ifhole.image!="hole.png"orhole.image[4:11]=="touched":#侦测是否不为空 hole.image="hole.png" hole.y+=65#角色的《特性》 hole.wait=random.randint(2,10)#刷新时间 else: hole.image=random.choice(["飞电鼠","编程猫"])+"-happy.png" hole.y-=65 hole.wait=3 music.play_once("跳.mp3") else: hole.wait-=1 wt=time.time() hammer.image="hammer1.png"#确保点击后锤子恢复 defon_mouse_down(pos):#当鼠标点击 globaldie,score#全局 ifdie==0:#还没喵 hammer.image="hammer2.png" forholeinholes: ifhole.image!="hole.png"andhole.image[4:11]!="touched": music.play_once("咚.mp3") ifhole.collidepoint(pos): ifhole.image=="编程猫-happy.png":#侦测是否打了编程猫 die=1 else: score+=1 hole.image=hole.image[:3]+"-touched.png" hole.wait=1 defon_mouse_move(pos):#锤子跟随 globaldie ifdie==0: hammer.x=pos[0] hammer.y=pos[1] pgzrun.go()
2023-08-17T20:49:11 点赞:0