xxxxxxxxxx
395
{
let salivaryGlands;
let mouth;
let esophagus;
let pancreas;
let stomach;
let smallIntestine;
let largeIntestine;
let words;
let organ;
let done;
let i;
let salivaryGlandsImg;
let bodyImg;
let mouthImg;
let esophagusImg;
let pancreasImg;
let stomachImg;
let smallIntestineImg;
let largeIntestineImg;
}
{
//This code has over seven thousand (7300-something) characters, which is the equivalent of over a thousand words or around five pages of writing.
//Teeth: Mash up the food
//Tongue: Moves stuff around in your mouth
//Appendix: Useless. Leftovers of a past thingamajig
//Rectum: Where poop is stored before exiting
//Anus: Where the poop comes out
//The complete digestive system! The digestive system's role is to:
//Break down food
//Absorb nutrients (It's your body's main source of materials)
//Makes energy (with help of other organ systems)
//Dispose of the extra stuff 'accordingly'
}
function preload() {
bodyImg = loadImage("body.png");
salivaryGlandsImg = loadImage("salivaryGlands.png");
mouthImg = loadImage("mouth.png");
esophagusImg = loadImage("esophagus.png");
pancreasImg = loadImage("pancreas.png");
stomachImg = loadImage("stomach.png");
smallIntestineImg = loadImage("smallIntestine.png");
largeIntestineImg = loadImage("largeIntestine.png");
}
function setup() {
createCanvas(800, 800);
noStroke();
salivaryGlands = new SalivaryGlands();
mouth = new Mouth();
esophagus = new Esophagus();
pancreas = new Pancreas();
stomach = new Stomach();
smallIntestine = new SmallIntestine();
largeIntestine = new LargeIntestine();
words = "";
organ = undefined;
done = false;
i = 0;
console.log("Assemble Roy's digestive system before the time runs out to win!");
console.log("Just kidding. There's no 30 second timer. I didn't want to add it. Would've been really easy, too. I was lazy. I'm sorry. I'm sorry.");
console.log("Anyways, have fun!");
}
function draw() {
background(220);
image(bodyImg, 0, 0, 800, 800);
words = "";
organ = undefined;
salivaryGlands.show();
mouth.show();
esophagus.show();
pancreas.show();
stomach.show();
smallIntestine.show();
largeIntestine.show();
salivaryGlands.update();
mouth.update();
esophagus.update();
pancreas.update();
stomach.update();
smallIntestine.update();
largeIntestine.update();
fill(0);
text(words, mouseX + 60, mouseY);
if (organ) {
organ.x = mouseX - organ.lenX / 2;
organ.y = mouseY - organ.lenY / 2;
}
if (done) {
i++;
if (i < 345) {
fill(255, 0, 0);
rect(i - 5, 145, 30, 15);
fill(0);
text("food", i, 155);
}
if (i > 500 && i < height) {
fill(255, 0, 0);
rect(340, i - 10, 40, 15);
fill(0);
text("poop", 345, i);
}
}
}
class SalivaryGlands {
constructor() {
this.lenX = 100;
this.lenY = 100;
this.x = random(0, width - this.lenX);
this.y = random(0, height - this.lenY);
}
show() {
image(salivaryGlandsImg, this.x, this.y, 100, 100);
}
update() {
if (this.x > 311 && this.x < 331) {
if (this.y > 85 && this.y < 105) {
this.x = 321;
this.y = 95;
return;
}
}
if (mouseX > this.x & mouseX < this.x + this.lenX) {
if (mouseY > this.y & mouseY < this.y + this.lenY) {
words = "Salivary glands: I produce saliva that breaks down starches and fats!";
if (mouseIsPressed) {
organ = salivaryGlands;
}
}
}
//this.x = 321;
//this.y = 95;
}
}
class Mouth {
constructor() {
this.lenX = 100;
this.lenY = 100;
this.x = random(0, width - this.lenX);
this.y = random(0, height - this.lenY);
}
show() {
image(mouthImg, this.x, this.y, 100, 100);
}
update() {
if (this.x > 311 && this.x < 331) {
if (this.y > 98 && this.y < 118) {
this.x = 321;
this.y = 108;
return;
}
}
if (mouseX > this.x & mouseX < this.x + this.lenX) {
if (mouseY > this.y & mouseY < this.y + this.lenY) {
words = "Mouth: I break down and physically mash up the food!";
if (mouseIsPressed) {
organ = mouth;
}
}
}
//this.x = 321;
//this.y = 108;
}
}
class Esophagus {
constructor() {
this.lenX = 100;
this.lenY = 100;
this.x = random(0, width - this.lenX);
this.y = random(0, height - this.lenY);
}
show() {
image(esophagusImg, this.x - 50, this.y - 50, 200, 200);
}
update() {
if (this.x > 309 && this.x < 329) {
if (this.y > 165 && this.y < 185) {
this.x = 319;
this.y = 175;
return;
}
}
if (mouseX > this.x & mouseX < this.x + this.lenX) {
if (mouseY > this.y & mouseY < this.y + this.lenY) {
words = "Esophagus: I push the food down to the stomach!";
if (mouseIsPressed) {
organ = esophagus;
}
}
}
//this.x = 319;
//this.y = 175;
}
}
class Pancreas {
constructor() {
this.lenX = 100;
this.lenY = 100;
this.x = random(0, width - this.lenX);
this.y = random(0, height - this.lenY);
}
show() {
image(pancreasImg, this.x, this.y, 100, 100);
}
update() {
if (this.x > 309 && this.x < 329) {
if (this.y > 279 && this.y < 299) {
this.x = 319;
this.y = 289;
return;
}
}
if (mouseX > this.x & mouseX < this.x + this.lenX) {
if (mouseY > this.y & mouseY < this.y + this.lenY) {
words = "Pancres: I make the enzymes that break down the fats, proteins, starches and sugars!";
if (mouseIsPressed) {
organ = pancreas;
}
}
}
//this.x = 319;
//this.y = 289;
}
}
class Stomach {
constructor() {
this.lenX = 100;
this.lenY = 100;
this.x = random(0, width - this.lenX);
this.y = random(0, height - this.lenY);
}
show() {
image(stomachImg, this.x - 50, this.y - 50, 200, 200);
}
update() {
if (this.x > 327 && this.x < 347) {
if (this.y > 241 && this.y < 261) {
this.x = 337;
this.y = 251;
return;
}
}
if (mouseX > this.x & mouseX < this.x + this.lenX) {
if (mouseY > this.y & mouseY < this.y + this.lenY) {
words = "Stomach: I use stomach acid to break down the food!";
if (mouseIsPressed) {
organ = stomach;
}
}
}
//this.x = 337;
//this.y = 251;
}
}
class SmallIntestine {
constructor() {
this.lenX = 100;
this.lenY = 100;
this.x = random(0, width - this.lenX);
this.y = random(0, height - this.lenY);
}
show() {
image(smallIntestineImg, this.x - 50, this.y - 50, 200, 200);
}
update() {
if (this.x > 310 && this.x < 330) {
if (this.y > 323 && this.y < 343) {
this.x = 320;
this.y = 333;
return;
}
}
if (mouseX > this.x & mouseX < this.x + this.lenX) {
if (mouseY > this.y & mouseY < this.y + this.lenY) {
words = "Small intestine: I absorb nutrients and water from the food!";
if (mouseIsPressed) {
organ = smallIntestine;
}
}
}
//this.x = 320;
//this.y = 333;
}
}
class LargeIntestine {
constructor() {
this.lenX = 200;
this.lenY = 200;
this.x = random(0, width - this.lenX);
this.y = random(0, height - this.lenY);
}
show() {
image(largeIntestineImg, this.x, this.y, 200, 200);
}
update() {
if (this.x > 263 && this.x < 283) {
if (this.y > 308 && this.y < 328) {
this.x = 273;
this.y = 318;
return;
}
}
if (mouseX > this.x & mouseX < this.x + this.lenX) {
if (mouseY > this.y & mouseY < this.y + this.lenY) {
words = "Large intestine: I absorb water, electrolytes, and nutrients from the food!";
if (mouseIsPressed) {
organ = largeIntestine;
}
}
}
//this.x = 273;
//this.y = 318;
}
}
function keyPressed() {
if (keyCode == 13) {
done = true;
console.log("The complete digestive system! The digestive system's role is to:");
console.log("Break down food");
console.log("Absorb nutrients (It's your body's main source of materials)");
console.log("Makes energy (with help of other organ systems)");
console.log("Dispose of the extra stuff 'accordingly'");
}
}