Functions
in
Share your Work
•
14 days ago
How do I change these to functions?
void setup(){size(200,200);ellipseMode(CENTER);rectMode(CENTER);}
void draw(){
background(0);
translate(X,Y);
rotate(r=(r+(t?.1:0))%TWO_PI);
stroke(39,242,29);
fill(255);
triangle(0,0,30,80,-30,80);
fill(39,242,29);
ellipse(0,5,60,60);
stroke(127);
line(10,20,-10,20);
fill(mouseX,0,mouseY);
ellipse(-19,0,16,25);
ellipse(19,0,16,25);
stroke(255);
line(-10,80,-20,100);
line(-20,100,-10,60);
line(10,80,20,100);
line(20,100,10,50);}
void keyPressed(){
if(key==CODED)
{if(keyCode==UP)Y--;
if(keyCode==DOWN)Y++;
if(keyCode==RIGHT)X++;
if(keyCode==LEFT)X--;}if(key=='t'){t=!t;}}
float X=100,Y=100,r;
boolean t;
1