猫史档案馆


你们谁看得懂?

用户:年兽是只屑年兽是只屑查看:0 回复:1 评论:0 创建时间:2023-05-03T19:05:13


from pgzrun import *
import random

WIDTH = 800
HEIGHT = 600
fish_list = []
score = 0
d = {'fish.png':1,'fish2.png':-1}

bg = Actor('grassland.png')
container = Actor('container.png')
print(container.image)
container.x = 400
container.y = 550
def create():
image_list = ['fish.png','fish2.png']
n = random.randint(0,1)
image = image_list[n]
fish = Actor(image)
fish.bottom = random.randint(-700,0)
fish.x = random.randint(0,WIDTH)
fish_list.append(fish)

clock.schedule_interval(create,0.35)

def draw():
screen.clear()
bg.draw()
container.draw()
for fish in fish_list:
fish.draw()
screen.draw.text(str(score),[120,50],'white',40)

def on_mouse_move(pos):
container.x = pos[0]

def update():
global score
for fish in fish_list:
fish.y += 3
if fish.top > HEIGHT:
fish.bottom = random.randint(-300,0)
fish.x = random.randint(0,WIDTH)
if container.colliderect(fish):
i = fish_list.index(fish)
fish_list.pop(i)
score += d[fish.image]

go()


回复

上一页1 页 / 共 1下一页
1111111111111111211111111111111112

欢迎加入codework工作室,共同研究python语言

链接编程猫社区-𝘊𝘰𝘥𝘦𝘸𝘰𝘳𝘬#-一起学编程 (codemao.cn)

点赞0


评论