用户:
Chengxuyee_已退查看:0 回复:0 评论:0 创建时间:2020-03-25T12:17:16
【作品展示】

【作品介绍】
在未来城市,科技已经接近巅峰,即使是一只猫消失在宇宙中也可以通过高科技雷达找回来。这不,现在恰好阿短的猫不见了,赶紧来寻找它吧!WSAD移动
U搜寻阿短周围是否有猫咪
【作品源代码】
import pgzrun
from random import randint
WIDTH = 800
HEIGHT = 600
get_cat = False
time_left = 15
game_over = False
game_start = False
man = Actor("man")
man.pos = 330, 330
cat = Actor("cat")
cat.pos = randint(100, 700), randint(100, 500)
music.play('dinglingling')
def draw():
screen.blit('space', (0, 0))
man.draw()
if get_cat:
cat.draw()
screen.draw.text("Time Left:" + str(time_left),
color="white",topleft=(10, 10),
fontsize=50)
if game_over:
screen.draw.text("You lost the cat",
topleft=(150, 260), fontsize=100)
music.pause()
def update():
global get_cat
if get_cat == False:
if keyboard.a:
man.x -= 1
elif keyboard.d:
man.x += 1
if keyboard.w:
man.y -= 1
elif keyboard.s:
man.y += 1
distance = man.distance_to(cat)
if distance <= 400:
music.set_volume(1 - distance / 450)
else:
music.set_volume(0.1)
if distance < 100 and keyboard.u:
get_cat = True
music.pause()
music.play_once('success')
def update_time_left():
global time_left,get_cat,game_over
if get_cat == False:
if time_left:
time_left -= 1
else:
game_over = True
clock.schedule_interval(update_time_left, 1.0)
pgzrun.go()
【提示】
部分含有Python第三方库相关内容的作品,在海龟编辑器网页端无法运行哦!如遇到这种情况,可以打开下面的链接,下载海龟编辑器客户端:
https://python.codemao.cn