GMU:Bots 'n' Plots/Apasri Titatarn: Difference between revisions

From Medien Wiki
No edit summary
No edit summary
Line 8: Line 8:


[[File:Cloud_bot_s.gif]]
[[File:Cloud_bot_s.gif]]
----Code----
<pre style="font-size:smaller" >
#cloud
width = 400
posx = [width/4,width/3,3*width/5,width/2,width/5,2*width/3,3.8*width/5,width/2.3]
def setup():
    size(400,400)
    background(255)
    frameRate(12)
 
   
   
def draw():
    noStroke()
    background(179,226,228)
    change= sin(frameCount*0.1)
    drawcloud(change)
    sx= width/2
    n = frameCount
    textsnow(posx,change)
 
    saveFrame("cloudbot##.jpg")
   
   
def drawcloud(change):
    print change
    fluffy = change*5
    fill(255)
    #cloud 1 S
    ellipse(1.25*width/5,0.9*height/1.8,80+fluffy,80+fluffy)
    #cloud 2 M
    ellipse(2*width/5,height/1.8-height/10,130+2*fluffy,120+1.5*fluffy)
    #cloud 3 L
    ellipse(2.7*width/5,0.95*height/1.8-height/10,120+fluffy,145+fluffy)
    #cloud 4 M
    ellipse(3.5*width/5,height/1.8-height/10,110+2.5*fluffy,110+2*fluffy)
   
    #face
    fill(80)
    ellipse(width/3,height/2,7,7)
    ellipse(2*width/3,height/2,7,7)
   
 
   
def textsnow(posx,change):
    fill(255)
    textSize(32)
    i=0
    while i <7:
        text("*",posx[i]+change*i,height/1.8+frameCount*(i+1)/5)
        i =i+1
</pre>

Revision as of 11:40, 29 April 2015

cloud my sheep robot. . . Sheep.png

Homework 2nd week

CloudBot

Cloud bot s.gif


Code----

#cloud
width = 400
posx = [width/4,width/3,3*width/5,width/2,width/5,2*width/3,3.8*width/5,width/2.3]

def setup():
    size(400,400)
    background(255)
    frameRate(12)
   
    
    
def draw():
    noStroke()
    background(179,226,228)
    change= sin(frameCount*0.1)
    drawcloud(change)
    sx= width/2
    n = frameCount
    textsnow(posx,change)
  
    saveFrame("cloudbot##.jpg")

    

    
def drawcloud(change):
    print change
    fluffy = change*5
    fill(255)
    #cloud 1 S
    ellipse(1.25*width/5,0.9*height/1.8,80+fluffy,80+fluffy)
    #cloud 2 M
    ellipse(2*width/5,height/1.8-height/10,130+2*fluffy,120+1.5*fluffy)
    #cloud 3 L
    ellipse(2.7*width/5,0.95*height/1.8-height/10,120+fluffy,145+fluffy)
    #cloud 4 M
    ellipse(3.5*width/5,height/1.8-height/10,110+2.5*fluffy,110+2*fluffy)
    
    #face
    fill(80)
    ellipse(width/3,height/2,7,7)
    ellipse(2*width/3,height/2,7,7)
    
   
    
def textsnow(posx,change):
    fill(255)
    textSize(32)
    i=0
    while i <7:
        text("*",posx[i]+change*i,height/1.8+frameCount*(i+1)/5)
        i =i+1