用户:
BUGQWQBUG查看:0 回复:0 评论:0 创建时间:2024-01-05T19:16:52
【作品展示】

【作品介绍】
希望大佬们的建议
【作品源代码】
import pgzrun, time
import fu
H= 500 #初始宽高
n= 5 #移动速度
k= 5 #增加速度
s="stop"
WIDTH = H
HEIGHT = H
TH = Actor('人物.png')
TH.pos = H/2,H/2
GJ = Actor("攻击.png")
GJ_DRAW = 0
DD = Actor("敌对.png")
x= 0
y=0
def draw():
screen.fill('black')
if s == "stop":
screen.draw.text("Fast Attack",color="dodgerblue",center=(H/2,H/2-50),fontsize=50)
screen.draw.text("Press any key to star",color="dodgerblue",center=(H/2,H/2),fontsize=30)
if s == "open":
TH.draw()
if GJ_DRAW == 1:
GJ.draw()
def update():
global WIDTH,HEIGHT,n,k,GJ_DRAW,x,y
if 1 == 0:
if WIDTH != 900 and HEIGHT != 900:
time.sleep(0.0001)
WIDTH += k
HEIGHT += k
if GJ_DRAW == 1 :
if GJ.collidepoint(DD.pos):
GJ_DRAW = 0
GJ.x += x
GJ.y += y
if keyboard.d:
TH.x+=n
if keyboard.a:
TH.x-=n
if keyboard.w:
TH.y-=n
if keyboard.s:
TH.y+=n
if GJ.x <= 0 :
WIDTH += 10
TH.x+=10
GJ.x = TH.x
GJ.y = TH.y
GJ_DRAW = 0
if GJ.x >= WIDTH:
WIDTH += 10
GJ.x = TH.x
GJ.y = TH.y
GJ_DRAW = 0
if GJ.y <= 0:
HEIGHT += 10
TH.y += 10
GJ.x = TH.x
GJ.y = TH.y
GJ_DRAW = 0
if GJ.y >= HEIGHT:
HEIGHT += 10
GJ.x = TH.x
GJ.y = TH.y
GJ_DRAW = 0
def on_key_down(key):
global s
if s == "stop":
s = "open"
def on_mouse_down(pos):
global s,GJ_DRAW,x,y,HEIGHT,WIDTH
if s == "open":
if GJ_DRAW == 0:
GJ.pos = TH.pos
GJ_DRAW = 1
x = (pos[0] - GJ.x)/(WIDTH/80)
y = (pos[1]-GJ.y)/(HEIGHT/80)
pgzrun.go()
【提示】
部分含有Python第三方库相关内容的作品,在海龟编辑器网页端无法运行哦!如遇到这种情况,可以打开下面的链接,下载海龟编辑器客户端:
https://python.codemao.cn