Advertisement
Guest User

My first Python robot (by Oliver Hannemann)

a guest
Apr 22nd, 2015
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.05 KB | None | 0 0
  1. """
  2.  
  3. My little Robot
  4.  
  5. """
  6.  
  7. def setup():
  8.     size(400, 400)
  9.     frameRate(10)
  10.  
  11.  
  12. def draw():
  13.    
  14.     r = random (225)
  15.     background(r, 150 ,r)
  16.    
  17.     pushMatrix()
  18.     translate(0,50)
  19.    
  20.     # 1. Antenne
  21.     pushMatrix()
  22.     translate(200, 100)
  23.     rotate(r/2)
  24.     line(0, 100, 0, 0)
  25.     popMatrix()
  26.  
  27.     # 2. Antenne
  28.     pushMatrix()
  29.     translate(200, 100)
  30.     rotate(-r/2)
  31.     line(0, 0, 0, 100)
  32.     popMatrix()
  33.    
  34.     # Kopf
  35.     ellipse(200, 100, 100, 100)
  36.    
  37.     # L Bein
  38.     pushMatrix()
  39.     translate(175, 145)
  40.     rotate(TWO_PI / 20)
  41.     line(0, 0, 0, 150)
  42.     popMatrix()
  43.    
  44.     # R Bein
  45.     pushMatrix()
  46.     translate(225, 145)
  47.     rotate(-TWO_PI / 20)
  48.     line(0, 0, 0, 150)
  49.     popMatrix()
  50.    
  51.     # L Schuh
  52.     pushMatrix()
  53.     translate(130, 285)
  54.     scale(-1, 1)
  55.     triangle(0, 0, 0, 30, 80, 40)
  56.     fill(255, 204, 0)
  57.     popMatrix()
  58.    
  59.     # R Schuh
  60.     pushMatrix()
  61.     translate(270, 285)
  62.     triangle(0, 0, 0, 30, 80, 40)
  63.     popMatrix()
  64.    
  65.     popMatrix()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement