xxxxxxxxxx
59
//declares variable for cat object
let cat;
//declares variable for background image
let img;
let catimg;
function setup() {
//creates canvas size for running the sketch
createCanvas(700, 600);
//creates new cat object with x and y positions
cat = new Cat(width, height);
function preload() {
// catimg = loadImage('kisspng-kitten-cat-hello-kitty-cartoon-clip-art-cat-faces-cartoons-images-5a87418fc16867.6726857415188135837922.png');
}
}
function draw() {
// catimg = loadImage('kisspng-kitten-cat-hello-kitty-cartoon-clip-art-cat-faces-cartoons-images-5a87418fc16867.6726857415188135837922.png');
//uploads background image to appear in the sketch
// loadImage('Mouse Cheese Background.jpg', img => {
// image(img, 0, 0, 700, 600);
// });
loadImage('catimg.png', img => {
image(img, 0, 0, 700, 600);
});
//declares and initializes variable for mouse object with x and y mouse positions
let mouse = createVector(mouseX, mouseY);
//displays both outer mouse ears with gray color
noStroke();
fill('gray');
ellipse(mouse.x - 15, mouse.y - 20, 25);
ellipse(mouse.x + 15, mouse.y - 20, 25);
//displays head of the mouse with gray color
fill('gray');
ellipse(mouse.x, mouse.y, 40);
//displays both mouse eyes with black color
fill(0);
ellipse(mouse.x - 8, mouse.y - 5, 5);
ellipse(mouse.x + 8, mouse.y - 5, 5);
//displays both inner mouse ears with pink color
fill('pink');
ellipse(mouse.x - 15, mouse.y - 20, 15);
ellipse(mouse.x + 15, mouse.y - 20, 15);
//declares and initializes variable for steering behavior of cat toward mouse
let steering = cat.arrive(mouse);
//object class function to apply force to cat's steering behavior
cat.applyForce(steering);
//object class function to display updates of cat's actions
cat.update();
//object class function to display drawing of cat
cat.show();
//object class function to display cat and mouse off the edge of the canvas
cat.edges();
// image(catimg,0,0,50,50);
}