User:Inge Hoonte/turtle

From XPUB & Lens-Based wiki
< User:Inge Hoonte
Revision as of 10:29, 14 June 2011 by Inge Hoonte (talk | contribs) (Created page with " b = random.randint(0, 55) h = random.randint(10,100) def building-straight(h): pd() fd(10); lt(90) fd(h); lt(90) fd(10); lt(90) fd(h); lt(90) # styles is a python ...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)


b = random.randint(0, 55) h = random.randint(10,100)

def building-straight(h):

 pd()
 fd(10); lt(90)
 fd(h); lt(90)
 fd(10); lt(90)
 fd(h); lt(90)
 # styles is a python dictionary
 r = random.randint(0, 255)
 styles['fill'] = rgb(r,r,r)
 pu()

import random

def building-angle(h)

 pd()
 lt(45)
 fd(8); lt(45)
 fd(h); lt(45)
 fd(8); lt(45)
 fd(h); lt(45)
 styles['fill'] = rgb(b,r,b)
 pu() 

def block-straight():

 startgroup()
 for i in range(10):
   building-straight(random.randint(10, 100))
   fd(10)
 endgroup()

def block-angle():

 startgroup()
 for i in range(10):
   building-angle(random.randomint(10,100))
 endgroup()

def block():

 startgroup()
 for i in range(2):
   block-straight(1)
   block-angle(1)
 endgroup()

block()

  1. goto(300, 200)
  2. face(0)
  3. building-straight(100)
  4. goto(300, 400)
  5. face(0)