用户:
田峻伟查看:0 回复:0 评论:0 创建时间:2023-07-07T09:38:51
【作品展示】

【作品介绍】
飞机大战
【作品源代码】
import pgzrun
import random
WIDTH = 480
HEIGHT = 852
score = 0
background = Actor("background")
hero = Actor("hero")
bullet = Actor("bullet")
enemy = Actor("enemy")
hero.x = WIDTH/2
hero.y = HEIGHT*2/3
bullet.y = -HEIGHT
enemy.x = WIDTH/2
enemy.y = 0
def draw():
background.draw()
hero.draw()
bullet.draw()
enemy.draw()
def update():
bullet.y = bullet.y - 10
enemy.y += 3
if enemy.y > HEIGHT:
enemy.y = 0
enemy.x = random.randint(60,400)
if bullet.colliderect(enemy):
enemy.y = 0
enemy.x = random.randint(0,WIDTH)
bullet.y = -HEIGHT
def on_mouse_move(pos):
hero.x = pos[0]
hero.y = pos[1]
def on_mouse_down():
bullet.x=hero.x
bullet.y=hero.y- 70
def on_mouse_down():
bullet.x = hero.x
bullet.y = hero.y - 70
pgzrun.go()
【提示】
部分含有Python第三方库相关内容的作品,在海龟编辑器网页端无法运行哦!如遇到这种情况,可以打开下面的链接,下载海龟编辑器客户端:
https://python.codemao.cn