/*
Fire Breathing Dragon
By: Jaylin Grierson
Date: September 21st, 2018
Description: As you move the mouse the dragon will move up and down
and the tail will move side to side. The background will transition from
black to orange and fire will appear as the mouse moves up and down. A message
will also be displayed when the mouse is clicked and the dragon will change colour
if a key is pressed.
*/
//===================================================================================
//Setup for the program
void setup(){
//Setting window size to 400 pixels by 400 pixels
size(400,400);
}
//===================================================================================
//Active code that refreshes as the program runs
void draw(){
//Setup for the design
//Setting frame rate to 60 frames per second
frameRate(60);
//Setting background colour to black
background(0);
//Setting the rectangle mode to corners
rectMode(CORNERS);
//Background
//Drawing a rectangle that changes from black to orange with the mouse's Y axis movement
fill(255,140,0,mouseY-125);
rect(0,0,400,400);
//The Dragon
//Moves up and down with mouse Y
//Body
//Setting stroke to invisible
noStroke();
//Setting fill colour to semi-transparent red purple
fill(150,0,255,200);
//Centre of body
rect(170, 110 + mouseY/3, 230, 190 + mouseY/3);
//Neck
quad(170, 110 + mouseY/3, 190, 90 + mouseY/3, 210, 90 + mouseY/3, 230, 110 + mouseY/3);
//Tail
//Base of tail
triangle(170, 190 + mouseY/3, 230, 190 + mouseY/3, 150 + mouseX/4, 280 + mouseY/3);
//Setting stroke colour to black
stroke(0);
//Setting fill colour to orange
fill(255,150,0,200);
//Tip of tail
triangle(150 + mouseX/4, 290 + mouseY/3, 145 + mouseX/4, 280 + mouseY/3, 155 + mouseX/4, 280 + mouseY/3);
//Arms and legs
//Setting stroke to invisible
noStroke();
//Setting fill colour to purple which becomes more red as mouse Y increases
fill(150 + mouseY/25,0,255,255);
//Right Arm
rect(210, 110 + mouseY/3, 230, 140 + mouseY/3);
//Left Arm
rect(170, 110 + mouseY/3, 190, 140 + mouseY/3);
//Right Leg
rect(210, 190 + mouseY/3, 230, 220 + mouseY/3);
//Left Leg
rect(170, 190 + mouseY/3, 190, 220 + mouseY/3);
//Wings
//Wings have inverse relationship to mouseY compared to the rest of the dragon
//Setting the stroke colour to black
stroke(0);
//Setting fill colour to yellow
fill(255,255,0,200);
//Right Wing, Inner Edge
triangle(230, 110 + mouseY/3, 300, 220 - mouseY/3, 300, 230 - mouseY/3);
//Left Wing, Inner Edge
triangle(170, 110 + mouseY/3, 100, 220 - mouseY/3, 100, 230 - mouseY/3);
//Right Wing, Outer Edge
triangle(300, 220 - mouseY/3, 300, 230 - mouseY/3, 380, 400 - mouseY);
//Left Wing, Outer Edge
triangle(100, 220 - mouseY/3, 100, 230 - mouseY/3, 20, 400 - mouseY);
//Setting fill colour to orange
fill(255,150,0,200);
//Right Wing, Inner Flap
triangle(230, 110 + mouseY/3, 300, 230 - mouseY/3, 310, 320 - mouseY/3);
//Left Wing, Inner Flap
triangle(170, 110 + mouseY/3, 100, 230- mouseY/3, 90, 320 - mouseY/3);
//Right Wing, Outer Flap
triangle(310, 320 - mouseY/3, 380, 400 - mouseY, 300, 230 - mouseY/3);
//Left Wing, Outer Flap
triangle(90, 320 - mouseY/3, 20, 400 - mouseY, 100, 230 - mouseY/3);
//Claws
//Setting fill colour to white
fill(255,255,255,200);
//Top Right Claw
triangle(170, 140 + mouseY/3, 190, 140 + mouseY/3, 180, 150 + mouseY/3);
//Top Left Claw
triangle(210, 140 + mouseY/3, 230, 140 + mouseY/3, 220, 150 + mouseY/3);
//Bottom Right Claw
triangle(210, 220 + mouseY/3, 230, 220 + mouseY/3, 220, 230 + mouseY/3);
//Bottom Left Claw
triangle(170, 220 + mouseY/3, 190, 220 + mouseY/3, 180, 230 + mouseY/3);
//Fire
//Tips of fire move back and forth as if flickering
//Setting fill colour to red
fill(255,0,0,255);
//Middle of Fire
quad(200, 90 + mouseY/3, 200 + mouseY/20, 90 + mouseY/1.7, 200 + 3*sin(frameCount/3), 90 + mouseY/1.5, 200 - mouseY/20, 90 + mouseY/1.7);
//Setting fill colour to yellow
fill(255,255,0,255);
//Right Side of Fire
quad(200, 90 + mouseY/3, 200 + mouseY/20, 90 + mouseY/1.7, 200 + mouseY/10 - 3*sin(frameCount/3), 90 + mouseY/1.6, 200 + mouseY/8, 90 + mouseY/1.8);
//Left Side of Fire
quad(200, 90 + mouseY/3, 200 - mouseY/20, 90 + mouseY/1.7, 200 - mouseY/10 - 3*sin(frameCount/3), 90 + mouseY/1.6, 200 - mouseY/8, 90 + mouseY/1.8);
//Head
//Setting stroke to invisible
noStroke();
//Setting fill colour to purple
fill(150,0,255,255);
//Base of Head
rect(180, 40 + mouseY/3, 220, 80 + mouseY/3);
//Nose
quad(180, 80 + mouseY/3, 220, 80 + mouseY/3, 210, 100 + mouseY/3, 190, 100 + mouseY/3);
//Setting stroke colour to black
stroke(0);
//Change fill colour to black
fill(0);
//Right Eye
triangle(205, 65 + mouseY/3, 210, 55 + mouseY/3, 215, 65 + mouseY/3);
//Left Eye
triangle(185, 65 + mouseY/3, 190, 55 + mouseY/3, 195, 65 + mouseY/3);
//Change fill colour to orange
fill(255,150,0,255);
//Right Horn
triangle(180, 40 + mouseY/3, 180, 10 + mouseY/3, 190, 40 + mouseY/3);
//Left Horn
triangle(210, 40 + mouseY/3, 220, 10 + mouseY/3, 220, 40 + mouseY/3);
//Change fill colour to yellow
fill(255,255,0,255);
//Centre Horn
quad(195, 40 + mouseY/3, 200, 20 + mouseY/3, 205, 40 + mouseY/3, 200, 50 + mouseY/3);
}
//===================================================================================
void mousePressed(){
//If the mouse button is pressed the line "RAWR!" will be printed in the text output area
println("RAWR!");
}
//===================================================================================
void keyPressed(){
//Pressing a key makes the dragon briefly change from purple to green
//Frame rate is reduced so the colour change lasts for one second
frameRate(1);
//Body
//Setting stroke to invisible
noStroke();
//Setting fill to dark green
fill(0, 200, 50);
//Centre of Body
rect(170, 110 + mouseY/3, 230, 190 + mouseY/3);
//Neck
quad(170, 110 + mouseY/3, 190, 90 + mouseY/3, 210, 90 + mouseY/3, 230, 110 + mouseY/3);
//Tail
//Base of Tail
triangle(170, 190 + mouseY/3, 230, 190 + mouseY/3, 150 + mouseX/4, 280 + mouseY/3);
//Setting stroke colour to black
stroke(0);
//Setting fill colour to orange
fill(255,150,0,200);
//Tip of tail
triangle(150 + mouseX/4, 290 + mouseY/3, 145 + mouseX/4, 280 + mouseY/3, 155 + mouseX/4, 280 + mouseY/3);
//Arms and Legs
//Setting stroke to invisible
noStroke();
//Setting fill colour to bright green
fill(0, 255, 0);
//Right Arm
rect(210, 110 + mouseY/3, 230, 140 + mouseY/3);
//Left Arm
rect(170, 110 + mouseY/3, 190, 140 + mouseY/3);
//Right Leg
rect(210, 190 + mouseY/3, 230, 220 + mouseY/3);
//Left Leg
rect(170, 190 + mouseY/3, 190, 220 + mouseY/3);
//Claws
//Setting fill colour to white
fill(255);
//Top Right Claw
triangle(170, 140 + mouseY/3, 190, 140 + mouseY/3, 180, 150 + mouseY/3);
//Top Left Claw
triangle(210, 140 + mouseY/3, 230, 140 + mouseY/3, 220, 150 + mouseY/3);
//Bottom Right Claw
triangle(210, 220 + mouseY/3, 230, 220 + mouseY/3, 220, 230 + mouseY/3);
//Bottom Left Claw
triangle(170, 220 + mouseY/3, 190, 220 + mouseY/3, 180, 230 + mouseY/3);
//Fire
//Setting fill colour to red
fill(255,0,0,255);
//Centre of Fire
quad(200, 90 + mouseY/3, 200 + mouseY/20, 90 + mouseY/1.7, 200 + 3*sin(frameCount/3), 90 + mouseY/1.5, 200 - mouseY/20, 90 + mouseY/1.7);
//Setting fill colour to yellow
fill(255,255,0,255);
//Right Side of Fire
quad(200, 90 + mouseY/3, 200 + mouseY/20, 90 + mouseY/1.7, 200 + mouseY/10 - 3*sin(frameCount/3), 90 + mouseY/1.6, 200 + mouseY/8, 90 + mouseY/1.8);
//Left Side of Fire
quad(200, 90 + mouseY/3, 200 - mouseY/20, 90 + mouseY/1.7, 200 - mouseY/10 - 3*sin(frameCount/3), 90 + mouseY/1.6, 200 - mouseY/8, 90 + mouseY/1.8);
//Head
//Setting fill colour to bright green
fill(0, 255, 0);
//Base of head
rect(180, 40 + mouseY/3, 220, 80 + mouseY/3);
//Nose
quad(180, 80 + mouseY/3, 220, 80 + mouseY/3, 210, 100 + mouseY/3, 190, 100 + mouseY/3);
//Setting stroke colour to black
stroke(0);
//Setting fill colour to black
fill(0);
//Right Eye
triangle(205, 65 + mouseY/3, 210, 55 + mouseY/3, 215, 65 + mouseY/3);
//Left Eye
triangle(185, 65 + mouseY/3, 190, 55 + mouseY/3, 195, 65 + mouseY/3);
}