Commit f81e50e8 by BellCodeEditor

auto save

parent 2bb58355
Showing with 11 additions and 8 deletions
import turtle import turtle
import random
def tree(n): def tree(n):
if n>=50: if n>=0:
pen.fd(n) pen.fd(n)
pen.rt(30) angle=random.randint(0,30)
tree(n-50) length=random.randint(1,15)
pen.lt(60) pen.rt(angle)
tree(n-50) tree(n-10)
pen.rt(30) pen.lt(2*angle)
tree(n-10)
pen.rt(angle)
pen.up() pen.up()
pen.bk(n) pen.bk(n)
pen.down() pen.down()
...@@ -20,5 +22,5 @@ w = turtle.Screen() ...@@ -20,5 +22,5 @@ w = turtle.Screen()
w.bgcolor('wheat') # wheat小麦 w.bgcolor('wheat') # wheat小麦
# 移动到起点 # 移动到起点
pen.lt(90) pen.lt(90)
tree(150) tree(100)
turtle.done() turtle.done()
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment