//Whack a Diglett! By Jessie Lo
//Interactive Toy Assignment
//Inspired by the video game series Pokemon, Diglett is a ground type pokemon
//Diglett is a tiny, brown Pokémon that seems to be perpetually buried within the earth, leaving only its head visible. Its small stature makes it both the lightest and shortest Ground-type Pokémon. It has beady black eyes and a large, round, pink nose
//references used
//http://www-acad.sheridanc.on.ca/PROG14998/lab-02/lab_02_24/index.html#
//http://www-acad.sheridanc.on.ca/PROG14998/2014/interactive-toy/interactive_toy_62/index.html
//Pre-setup
boolean malletHit = false;
float eyesX = 0;
float eyesY = 0;
float deadeyesX = 0;
float deadeyesY = 0;
//Setup (size of screen, etc)
void setup() {
size (400, 400);
rectMode(CENTER);
noCursor();
}
//Eyes
void drawEyes () {
fill(0);
ellipse( 180, 180, 10, 30);
ellipse(218, 180, 10, 30);
fill(255);
ellipse(181, 172, 5, 10);
ellipse(220, 172, 5, 10);
}
//Dead eyes
void drawDeadeyes () {
stroke(0);
strokeWeight(5);
line(167, 150, 190, 176);
line(190, 150, 165, 175);
line(210, 150, 230, 175);
line(230, 150, 210, 175);
noStroke ();
}
void draw() {
//List what to draw in order
background(255);
drawSky();
drawDiglett();
drawGround();
drawBorder();
//Mallet controls
//Determines position and functions of the Mallet
//Mallet (mouse should disapear from screen and become the Mallet)
if (!malletHit) {
fill(67, 41, 4);
stroke(67, 41, 4);
line(mouseX+65, mouseY-50, mouseX+65, mouseY+50);
noStroke();
ellipse(mouseX+45, mouseY-50, 40, 40);
rect(mouseX+70, mouseY-50, 50, 40);
fill(160, 108, 40);
ellipse(mouseX+90, mouseY-50, 40, 40);
}
//Mallet in the hitting position (when mouse is clicked)
else {
//The "BAM", helps visually show the Mallet has hit something
noStroke();
fill(255, 234, 0);
triangle(mouseX, mouseY+20, mouseX, mouseY-20, mouseX-40, mouseY);
triangle(mouseX-20, mouseY, mouseX, mouseY+40, mouseX+20, mouseY);
triangle(mouseX-20, mouseY, mouseX+20, mouseY, mouseX+30, mouseY+30);
triangle(mouseX-20, mouseY, mouseX+20, mouseY, mouseX-30, mouseY+30);
fill(67, 41, 4);
strokeWeight(10);
stroke(67, 41, 4);
line(mouseX, mouseY-20, mouseX+90, mouseY-20);
noStroke();
ellipse(mouseX, mouseY, 40, 40);
rect(mouseX, mouseY - 20, 40, 50);
fill(160, 108, 40);
ellipse(mouseX, mouseY-40, 40, 40);
}
//noStroke();
}
// When mouse is pressed, Mallet attacks what is targeted (can be anywear on screen)
void mousePressed() {
if (!malletHit) {
malletHit = true;
}
}
//If mouse click is "released", Mallet is back in original position
//Works with dragging the mouse around as well
void mouseReleased() {
mousePressed = false;
malletHit = false;
}
void mouseDragged() {
mousePressed = false;
}
//Black Border surrounds the screen
void drawBorder() {
fill(0);
rect(1, 200, 38, 400);
rect(399, 200, 38, 400);
rect(200, 1, 400, 38);
rect(200, 399, 400, 38);
}
//Draw Sky + Clouds
void drawSky() {
noStroke();
fill(77, 147, 255);
rect( 200, 200, 360, 360);
//Clouds move to the right of the screen at their respective speeds
fill(255, 150);
rect(120 + (frameCount/1.6), 60, 80, 50, 10);
fill(255, 220);
rect(145 + (frameCount/1.6), 70, 40, 30, 10);
fill(255, 220);
rect(1 + (frameCount/2), 120, 40, 30, 10);
fill(255, 250);
rect(-20 + (frameCount/4), 60, 80, 50, 10);
fill(255, 220);
rect(-20 + (frameCount/6), 170, 40, 30, 10);
fill(255);
rect(210 + (frameCount/5), 190, 80, 50, 10);
}
//Draw Ground
//The darker the colour, the deeper/richer the soil
void drawGround() {
noStroke();
fill(129, 88, 0);
rect(200, 320, 360, 130);
fill(165, 113, 0);
rect(200, 300, 360, 100);
fill(206, 141, 0);
rect(200, 280, 360, 70);
}
//Draw Diglett
//Will draw Digletts's Body, Eyes and Nose in that order
void drawDiglett() {
//Body
noStroke();
fill (80, 26, 5);
ellipse( 200, 200, 110, 150);
if (mousePressed) {
drawDeadeyes ();
} else {
drawEyes ();
}
//Nose
fill( 255, 173, 207);
ellipse (200, 200, 50, 35);
fill (255);
ellipse (190, 192, 20, 10);
}