Moles that move

Joined
Mar 23, 2023
Messages
5
Reaction score
0
Hello, I'm working with this code from a Khan Academy assignment and I'm wondering how I would animate to get the moles to move randomly within a bounded wall off of which they would bounce off??

Thanks so much-

var drawMole = function(moleX, moleY) {


noStroke();
fill(125, 93, 43);
ellipse(moleX, moleY, 60, 60); // face
fill(255, 237, 209);
ellipse(moleX, moleY+10, 33, 28);
fill(0, 0, 0);
ellipse(moleX-10, moleY-15, 10, 10); // eyes
ellipse(moleX+10, moleY-15, 10, 10);
ellipse(moleX, moleY-5, 10, 10); // nose
ellipse(moleX, moleY+10, 20, 5); // mouth
};

background(52, 168, 83); // green grass
fill(0, 0, 0);
ellipse(200, 200, 100, 30); // holes!
ellipse(70, 119, 100, 30);
ellipse(300, 60, 100, 30);
ellipse(297, 350, 100, 30);

drawMole(200, 186);
drawMole(297, 329);
drawMole(69, 101);
drawMole(290, 32);
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,983
Messages
2,570,187
Members
46,747
Latest member
jojoBizaroo

Latest Threads

Top