So basically I have these 2 sets of code. One is supposed to be a superhero and the other is a villain (im not artsy). For this new assignment, what I need to do is take both sets of code and encapsulate them into function(s) onto a whole new blank document...so both the villain and superhero are on the same page. I'm unsure where to start.
Code
var xPos = 250;
var yPos = 200;
var x_one = 210;
var y_one = 230;
var x_two = 250;
var y_two = 200;
var x_three = 290;
var y_three = 230;
draw = function() {
background(113, 230, 230);
//grass
noStroke();
fill(25, 204, 61);
rect(0, 300, 410, 300);
//cape
fill(255, 0, 0);
triangle(x_one, y_one, x_two, y_two, x_three, y_three);
//ghost hero
fill(20, 18, 18);
ellipse(xPos, yPos, 30, 30);
xPos = xPos-2;
yPos = yPos-2;
x_one = x_one-2;
y_one = y_one-2;
x_two = x_two-2;
y_two = y_two-2;
x_three = x_three-2;
y_three = y_three-2;
};
Code
noStroke();
background(8, 8, 8);
//moon
fill(196, 188, 188);
ellipse(50,50,50,50);
//appendage
fill(255, 0, 0);
stroke(0, 89, 255);
rect(153,185,45,150);
//head
triangle(100,185,250,185,174,100);
//eyes
stroke(13, 28, 4);
fill(145, 127, 47);
ellipse(160,140,15,15);
ellipse(190,140,15,15);
//mouth
noFill();
line(160,165,190,165);
//ears
fill(179, 16, 16);
ellipse(138,120,25,35);
ellipse(211,120,25,35);
This post was edited by Shakti on Sep 22 2016 04:34pm