""" 04_迷宫游戏_鼠标牵引.py """ from sprites import Sprite,mouse_pos def collision_check(): laoshu.nextshape() # 下一个造型 if laoshu.collidecolor(black): # 如果碰到黑色则倒退4 laoshu.bk(4) elif laoshu.collidecolor(green):# 否则如果碰到绿色则返回真 return True maze = Sprite('2.png') maze.ondrag(None) screen = maze.getscreen() laoshu = Sprite(['res/rat1.png','res/rat2.png']) laoshu.scale(0.4) screen.listen() black = (0,0,0) green = (0,255,85) while True: m = mouse_pos() laoshu.heading(m) if laoshu.distance(m)>=10: laoshu.fd(2) t = collision_check() # 调用函数,并且返回t if t:break # 如果t是真,则中断while循环 screen.update() w = Sprite(visible=False) w.color('red') w.write('Game Over',align='center',font=('',100,'normal')) screen.mainloop()
-
归档
- 2025 年 3 月
- 2025 年 2 月
- 2025 年 1 月
- 2024 年 12 月
- 2024 年 8 月
- 2024 年 6 月
- 2024 年 5 月
- 2024 年 4 月
- 2024 年 3 月
- 2024 年 2 月
- 2023 年 11 月
- 2023 年 9 月
- 2023 年 6 月
- 2023 年 5 月
- 2023 年 4 月
- 2023 年 3 月
- 2023 年 2 月
- 2023 年 1 月
- 2022 年 12 月
- 2022 年 11 月
- 2022 年 10 月
- 2022 年 9 月
- 2022 年 8 月
- 2022 年 7 月
- 2022 年 6 月
- 2022 年 5 月
- 2022 年 4 月
- 2022 年 3 月
- 2022 年 2 月
- 2022 年 1 月
- 2021 年 12 月
- 2021 年 11 月
- 2021 年 10 月
- 2021 年 9 月
- 2021 年 8 月
- 2021 年 7 月
- 2021 年 6 月
- 2021 年 5 月
- 2021 年 4 月
- 2021 年 3 月
- 2021 年 2 月
- 2021 年 1 月
- 2020 年 12 月
- 2020 年 11 月
- 2020 年 10 月
- 2020 年 9 月
- 2020 年 8 月
- 2020 年 7 月
- 2020 年 6 月
- 2020 年 5 月
- 2020 年 4 月
- 2020 年 3 月
- 2020 年 2 月
- 2020 年 1 月
- 2019 年 12 月
- 2019 年 11 月
- 2019 年 10 月
- 2019 年 9 月
- 2019 年 8 月
- 2019 年 7 月
- 2019 年 6 月
- 2019 年 5 月
- 2019 年 4 月
- 2019 年 3 月
- 2019 年 2 月
- 2018 年 3 月
- 2018 年 1 月
- 2017 年 9 月
- 2017 年 5 月
- 2017 年 1 月
-
功能