Your browser does not support the canvas tag.

previous        Show / Hide Source        Download        next
/*
title: how to educate a dragon to breathe fire
author: Zhuosheng Luo
 A little dragon practises to breathe fire. He wants to hit the target but he always 
 misses, and finally he succeeds to do it by breathing powerful fire.
*/


//background
void setup(){

size(400,400);
rectMode(CORNERS);
noStroke();

}
void draw(){
  //FPS
frameRate(60);

//set background colorto grey
background(170,170,170);

fill(255,85,79);// fire
ellipse(mouseX-120,250,30,30);
triangle(mouseX-120,230,mouseX-120,270,mouseX-135,250);
triangle(mouseX-90,250,mouseX-110,240,mouseX-110,260);
ellipse(mouseX-90+sin(frameCount)*5,240,20,5);
ellipse(mouseX-90+sin(frameCount)*5,260,20,5);
ellipse(mouseX-80+sin(frameCount)*5,250,20,5);

//teeth
fill(255,255,255);//set color to white
triangle(180,220,200,220,190,240);
triangle(200,220,220,220,210,240);
triangle(220,220,240,220,230,240);
triangle(180,260,180,280,200,280);
triangle(210,250,200,270,220,260);
triangle(230,250,220,260,240,260);


//light yellow
fill(245,226,162);//set color to light yellow
quad(180,320,180,280,220,260,220,300);
quad(220,300,220,260,260,240,260,320);
triangle(260,240,320,240,260,320);

  
//light red 
fill(255,85,79);//set color to light red
quad(180,180,180,220,260,240,260,180);
quad(260,180,320,180,320,220,260,240);

//black thorn
fill(67,67,67);//set color to black
quad(160,220,160,200,180,180,180,220);
quad(160,220,180,220,175,240,175,240);
triangle(180,180,220,160,220,180);
quad(220,170,220,180,260,180,260,150);
quad(260,170,260,180,320,180,320,140);
triangle(320,180,320,220,360,200);
triangle(290,300,280,320,300,320);

//dark red
fill(175,35,30);//set color to dark red
quad(260,240,320,220,360,300,300,320);

//eye ball (white)
fill(255,255,255);//set color to white
ellipse(270,205,20,20);

//eye brow and pupil
fill(67,67,67);//set color to black
ellipse(266-mouseX/1000,200+mouseX/35,10,10);
quad(255,200,265,185,260,185,250,200);

//target
fill(143,88,38);
rect(15,400,25,mouseX);
fill(0,0,0);
ellipse(20,mouseX,30,105);
fill(255);
ellipse(20,mouseX,25,100);
fill(255,0,0);
ellipse(25,mouseX,5,10);


}
void mousePressed() {
  //FPS
  frameRate(1);
//set background color to grey
background(170,170,170);

//target
fill(143,88,38);
rect(15,400,25,280);
fill(0,0,0);
ellipse(20,255,30,105);
fill(255);
ellipse(20,255,25,100);
fill(255,0,0);
ellipse(25,255,5,10);

//a grey square to cover the target, so the target will look like being destroyed
fill(170,170,170);
rect(0,220,100,290);

//fire with maximum power
fill(255,213,151);//fire
rect(0,230,290,280);

//upper teeth
fill(255,255,255);//set color to white
triangle(180,220,200,220,190,240);
triangle(200,220,220,220,210,240);
triangle(220,220,240,220,230,240);

//bottom teeth
triangle(182,277,187,294,198,285);
triangle(206,280,210,260,227,265);
triangle(230,262,230,255,235,257);


//light yellow part
fill(245,226,162);//set color to light yellow
quad(188,293,198,333,234,303,221,270);
quad(220,270,233,303,276,315,260,240);
triangle(260,240,320,240,275,315);


//light red
fill(255,85,79);//set color to light red
quad(180,180,180,220,260,240,260,180);
quad(260,180,320,180,320,220,260,240);

//black thorn
fill(67,67,67);//set color to black
quad(160,220,160,200,180,180,180,220);
quad(160,220,180,220,175,240,175,240);
triangle(180,180,220,160,220,180);
quad(220,170,220,180,260,180,260,150);
quad(260,170,260,180,320,180,320,140);
triangle(320,180,320,220,360,200);
triangle(290,300,280,320,300,320);

//dark red
fill(175,35,30);//set color to dark red
quad(260,240,320,220,360,300,300,320);


//eye ball
fill(255,255,255);//set color to white
ellipse(270,205,20,20);

//pupil and eye brow
fill(67,67,67);//set color to black
ellipse(265,205,10,10);
quad(255,200,265,185,260,185,250,200);

}