資源簡介
turtle實現了一個跳房子游戲
每次才對就會增加難度
一共十關
有些不應該輸出的東西(海龜的坐標,正確答案等等。。。)
turtle不用安裝,直接就有(也就是標準庫)。
代碼片段和文件信息
#1.田字格
#2.隨機出現三次
#3.輸入順序
#4.對:進入下一關、多一個格子
#5.錯:再給一次機會,與本回合第一次出現的順序一樣
import?turtlerandomtime?as?ti
t=turtle.Turtle()
t.speed(0)
#t.ht()
def?goto2(xy):
????t.up()
????t.goto(xy)
????t.down()
c=[‘red‘‘orange‘‘green‘‘blue‘‘purple‘‘yellow‘]
for?k?in?range(4):
????t.begin_fill()
????t.color(c[k%4])
????for?x?in?range(4):
????????t.fd(100)
????????t.rt(90)
????t.end_fill()
????t.lt(90)
????t.color(‘green‘)
t.color(‘black‘)
t.up()
t.goto(-2010)
t.write(‘1??????????????????????????2‘)
t.up()
t.goto(-20-90)
t.write(‘3??????????????????????????4‘)
t.ht()
t.down()
y=turtle.Turtle()
y.shape(‘turtle‘)
li=[[-5050][5050][-50-50][50-50]]
aj=1
qw=5
for?x?in?range(10):
????s=‘‘
????d=[]
????if?(x%3==0)&(x!=0):
????????goto2(-1000-(100*aj))
????????print(-1000-(100*aj))
????????t.color(‘black‘c[random.randint(0len(c)-1)])
????????t.begin_fill()
????????for?i?in?range(4):
????????????t.up()
????????????t.fd(100)
????????????t.rt(90)
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件???????2659??2020-05-06?17:01??turtle跳房子.py
-----------?---------??----------?-----??----
?????????????????2659????????????????????1
- 上一篇:python 人群計數
- 下一篇:pygame貪吃蛇
評論
共有 條評論