xxxxxxxxxx
33
// check file called "Download_first_sketch_as_PNG.js" to see the code for my first sketch and the code I used to download the frog as a PNG to be used in this final project.
// to commence sketch, use your mouse to click anywhere on the putple cavas as many times as you wish. There will only be a maximum of five frogs on the screen at any given time. Do not be alarmed as that is an intended characteristic of my sketch.
let frogs = [];
// preload function and loadImage to have the frog I made from Module 1 loaded and ready to manipulate
function preload() {
frogPng = loadImage("DopeyFrog.png");
}
function setup() {
createCanvas(400, 400);
}
// A function that creates new frog heads when the mouse is pressed
function mousePressed() {
frogs.push(new Frog(mouseX, mouseY));
}
function draw() {
background(105, 125, 255);
for (let i = 0; i < frogs.length; i++) {
let f = frogs[i];
f.move();
f.display();
}
// if more than 5 frogs are pressed into existence, then use splice to replace the oldest one with a new frog
if (frogs.length > 5) {
frogs.splice(0, 1);
}
}