Animate object in javascript?


#1

ok so I’m trying to make an object move with javascript I saw something on khanacademy`noStroke();

// the starting size for the sun

var sunSize = 30;
draw = function() {

background(82, 222, 240);


// The sun
fill(255, 204, 0);
ellipse(200, 298, sunSize, sunSize);

// The land
fill(76, 168, 67);
rect(0, 300, 400, 100);

sunSize = sunSize + 1;
};
`
if anyone knows how plz let me know
this is my code and some of khanaceademy
var p2 = 30;
draw = function() {

background(82, 222, 240);


// The sun
fill(255, 204, 0);
ellipse(200, 298, sunSize, sunSize);

// The land
fill(76, 168, 67);
rect(0, 300, 400, 100);

p2 = p2 + 1;
};


#2

Oh that one is easy :smile:
Move the var sunSize = 30 into the function :slight_smile:


#3

ooooooooo heh thnx well I’ll tht then