猫史档案馆


【Python作品分享】水晶

用户:冷静的乌力力I0Em冷静的乌力力I0Em查看:0 回复:0 评论:0 创建时间:2021-03-14T16:16:16


【作品展示】

center_image

 

【作品介绍】

哈哈

 

【作品源代码】

from arcade import *
import random
class MyWindow(Window):
    def __init__(self):
        super().__init__(1200, 600, "拖拉晶")
        self.bg = Sprite("bg.png")
        self.bg.left = 0
        self.bg.bottom = 0
        self.c_l = SpriteList()
        self.create_c()
        self.a = Sprite("airship.png")
        self.a.position = 0,300
        self.a.change_x = 0.5
        self.cnt = 0
    def is_hit(self):
        h_l=check_for_collision_with_list(self.a,self.c_l)
        for i in h_l:
            self.c_l.remove(i)
            self.cnt += 1
    def create_c(self):
        for i in range(500):
            self.c = Sprite("crystal.png")
            self.c.center_x = random.randint(0,1200)
            self.c.center_y = random.randint(0,600)
            self.c_l.append(self.c)        
    def on_draw(self):
        start_render()
        self.bg.draw()
        self.c_l.draw()
        self.a.draw()
        draw_text(f"Count:{self.cnt}",50,550,(255,0,0),30)
    def on_mouse_drag(self, x, y, dx, dy, button, modifiers):
        d_l=get_sprites_at_point((x,y),self.c_l)
        for i in d_l:
            i.position = x,y
    def on_update(self,time):
        self.a.update()
        self.is_hit()
w = MyWindow()
run()

 

【提示】

部分含有Python第三方库相关内容的作品,在海龟编辑器网页端无法运行哦!如遇到这种情况,可以打开下面的链接,下载海龟编辑器客户端:

https://python.codemao.cn


回复

上一页1 页 / 共 0下一页