//Lantern festival - Rae Barclay
//use the arrow keys to walk...maybe you'll find what you're looking for...
nagashi object1 = new nagashi(); //setup nagashi as object1
stars[] starry = new stars[200]; //setup the star array to draw 200 stars
lanternBackground[] lantern = new lanternBackground [15]; //setup the star array to draw 10 copies of the lanternBackground
lanterns object2 = new lanterns(); //setup lanterns as a new object
float sideScroll;
float cloudX;
float bg = 0;
float cloakX = 1;
float cloakY = 1;
float hairX =1;
float hairY = 1;
float highest = 0;
float lowest = 10;
float upAndDown;
float hairTailX = 1; //I was going to try and do some hair animation, but I never got around to it, so these Variables are just leftovers
float hairTailY = 1; //same haha
float legsX = 1;
float legsY = 1;
float shadowX = 1;
float shadowY =1;
float shadowR =60;
float bodyX = 1;
float bodyY =1;
float beadX = 1;
float beadY = 1;
float inverse;
float fade;
float delaytime = 1000;
float count_up;
float count_down;
float fadeOut=255;
float startTime;
void setup() {
size(800, 600);
background(0);
noStroke();
rectMode(CORNERS);
//array to draw the lanterns in the background
for (int x = 0; x < lantern.length; x++)
lantern[x] = new lanternBackground(int(random(-100, 800)), int(random(450, 455)));
//array to draw the flickering stars in the background
for (int i = 0; i < starry.length; i++) {
starry[i] = new stars(int(random(0, 800)), int(random(0, 500)));
}
}
void draw() {
fill(19, 07, 48);
rect(0, 500, 800, 0);
//draw the gradient in the sky
float gradient=0;
while (gradient >=0 && gradient<500) {
fill(204, 98, 126, 5);
rect(0, gradient, 800, 550);
gradient=gradient+20;
}
//draw the stars according to the length of the screen
for (int i = 0; i < starry.length; i++) {
starry[i].drawStars();
}
//draw the lanterns according to the length of the screen
for (int x = 0; x<lantern.length; x++) {
lantern[x].drawLanterns();
}
drawClouds();
drawBackground();
object2.drawLantern();
drawSword();
object1.drawNagashi();
//fade out
if (cloakX >549) {
if (millis() - startTime < delaytime) {
startTime = millis();
count_down = delaytime - count_up;
if (fadeOut == 0) {
count_up=delaytime;
}
if (fadeOut == 255) {
count_up = delaytime;
}
fade = 75 / (2*delaytime / count_down);
fadeOut = floor(fade);
} else {
fadeOut = fadeOut -5;
}
}
}void drawBackground() {
fill(22, 41, 48);
rect(0, 500, 800, 600);
ellipse(0+sideScroll, 510, 300+sideScroll, 60);
ellipse(300+sideScroll, 500, 450+sideScroll, 40);
ellipse(500+sideScroll, 495, 1000+sideScroll, 30);
ellipse(1000+sideScroll, 500, 100+sideScroll, 20);
//moves the background along as the keys are pressed
if (keyPressed) {
if (bg<=550) {
if (keyCode == RIGHT) {
sideScroll = sideScroll -2;
bg=bg+1;
}
if (keyCode == LEFT) {
sideScroll =sideScroll +2;
bg=bg+1;
}
}
}
}
void drawClouds() {
fill(208, 235, 240, 75);
rect(cloudX+20, 40, cloudX+100, 68, 20);
rect(cloudX+250, 100, cloudX+426, 150, 45);
rect(cloudX+990, 325, cloudX+1100, 350, 20);
rect(cloudX+750, 250, cloudX+805, 290, 30);
rect(cloudX+500, 250, cloudX+540, 275, 20);
rect(cloudX+400, 340, cloudX+425, 360, 25);
rect(cloudX+750, 150, cloudX+850, 165, 25);
rect(cloudX+100, 300, cloudX+160, 330, 40);
rect(cloudX+1500, 230, cloudX+1550, 275, 20);
rect(cloudX+700, 75, cloudX+850, 150, 30);
rect(cloudX+150, 155, cloudX+180, 171, 20);
rect(cloudX+300, 310, cloudX+315, 325, 20);
fill (252, 212, 214, 75);
rect(cloudX+30, 50, cloudX+120, 80, 40);
rect(cloudX+220, 85, cloudX+400, 125, 80);
rect(cloudX+160, 125, cloudX+460, 165, 80);
rect(cloudX+1000, 335, cloudX+1125, 365, 30);
rect(cloudX+1225, 210, cloudX+1360, 230, 40);
rect(cloudX+490, 258, cloudX+550, 290, 50);
rect(cloudX+385, 335, cloudX+450, 370, 30);
rect(cloudX+720, 120, cloudX+800, 160, 30);
rect(cloudX+60, 315, cloudX+155, 340, 40);
rect(cloudX+1450, 200, cloudX+1525, 260, 30);
rect(cloudX+65, 10, cloudX+90, 33, 30);
//makes the clouds float along
cloudX= cloudX - .10;
}
class lanternBackground {
float lanternLocation = 3; //makes the x value of the lanterns when they're drawn a lot larger than it needs to be, for aesthetic purposes
float shift;
PVector lanternBG =new PVector (0, 0); //used to place the lanterns in the array
lanternBackground(float tempX, float tempY) {
lanternBG.x=tempX;
lanternBG.y=tempY;
}
void drawLanterns() {
fill(25, 1, 6);
quad(((lanternBG.x+205)+sideScroll*.25)*lanternLocation, (500)+shift, ((lanternBG.x+204)+sideScroll*.25)*lanternLocation, (500)+shift, ((lanternBG.x+195)+sideScroll*.25)*lanternLocation, (440)+shift, ((lanternBG.x+196)+sideScroll*.25)*lanternLocation, (440)+shift);
quad(((lanternBG.x+196)+sideScroll*.25)*lanternLocation, (443)+shift, ((lanternBG.x+196)+sideScroll*.25)*lanternLocation, (446)+shift, ((lanternBG.x+190)+sideScroll*.25)*lanternLocation, (448)+shift, ((lanternBG.x+190)+sideScroll*.25)*lanternLocation, (445)+shift);
stroke(2);
line(((lanternBG.x+190)+sideScroll*.25)*lanternLocation, (445)+shift, ((lanternBG.x+190)+sideScroll*.25)*lanternLocation, (448)+shift);
noStroke();
fill(25, 1, 6);
quad(((lanternBG.x+225)+sideScroll*.25)*lanternLocation, (500)+shift, ((lanternBG.x+224)+sideScroll*.25)*lanternLocation, (500)+shift, ((lanternBG.x+224)+sideScroll*.25)*lanternLocation, (445)+shift, ((lanternBG.x+225)+sideScroll*.25)*lanternLocation, (445)+shift);
quad(((lanternBG.x+225)+sideScroll*.25)*lanternLocation, (453)+shift, ((lanternBG.x+225)+sideScroll*.25)*lanternLocation, (456)+shift, ((lanternBG.x+230)+sideScroll*.25)*lanternLocation, (456)+shift, ((lanternBG.x+230)+sideScroll*.25)*lanternLocation, (453)+shift);
stroke(2);
line(((lanternBG.x+230)+sideScroll*.25)*lanternLocation, (453)+shift, ((lanternBG.x+230)+sideScroll*.25)*lanternLocation, (456)+shift);
noStroke();
fill(20, 200, 145, int(random(50, 100)));
ellipse(((lanternBG.x+230)+sideScroll*.25)*lanternLocation, (461)+shift, 5, 5);
fill(247, 220, 145, 190);
ellipse(((lanternBG.x+230)+sideScroll*.25)*lanternLocation, (461)+shift, 2, 2);
fill(20, 200, 145, int(random(50, 100)));
ellipse(((lanternBG.x+190)+sideScroll*.25)*lanternLocation, (453)+shift, 5, 5);
fill(247, 220, 145, 190);
ellipse(((lanternBG.x+190)+sideScroll*.25)*lanternLocation, (453)+shift, 2, 2);
shift = 10;
}
}class lanterns {
void drawLantern() {
fill(25, 1, 6);
rect(1850+sideScroll, 560, 1864+sideScroll, 260, 20);
quad(1800+sideScroll, 300, 1800+sideScroll, 314, 1850+sideScroll, 314, 1850+sideScroll, 300);
ellipse(1800+sideScroll, 307, 7, 7);
stroke(25, 1, 6);
line(1805+sideScroll, 310, 1805+sideScroll, 330);
noStroke();
fill(240, 183, 24, int(random(100, 150)));
ellipse(1805+sideScroll, 340, 6, 6);
fill(20, 200, 145, int(random(50, 75)));
ellipse(1805+sideScroll, 340, 5, 5);
ellipse(1805+sideScroll, 340, 7.5, 7.5);
ellipse(1805+sideScroll, 340, 10, 10);
ellipse(1805+sideScroll, 340, 12.5, 12.5);
ellipse(1805+sideScroll, 340, 15, 15);
ellipse(1805+sideScroll, 340, 17.5, 17.5);
ellipse(1805+sideScroll, 340, 20, 20);
fill(22, 41, 48);
ellipse(1850+sideScroll, 560, 10, 4);
ellipse(1860+sideScroll, 560, 5, 5);
}
}class nagashi {
void drawNagashi() {
stroke(246, 237, 249, fadeOut);
fill(194, 179, 198, fadeOut);
quad((cloakX + 44), (cloakY + 331), (cloakX + 59), (cloakY + 338), (cloakX + 59), (cloakY + 349), (cloakX+ 49), (cloakY+ 349));
triangle((cloakX + 59), (cloakY + 349), (cloakX+ 49), (cloakY + 349), (cloakX + 62), ( cloakY + 470));
quad((cloakX+ 49), (cloakY + 349), (cloakX + 62), (cloakY + 470), (cloakX + 55), (cloakY + 479), (cloakX+ 39), (cloakY + 479));
quad((cloakX + 55), (cloakY + 449), (cloakX + 39), (cloakY + 479), (cloakX + 39), (cloakY + 509), (cloakX + 59), (cloakY + 509));
quad((cloakX + 62), (cloakY + 399), (cloakX + 59), (cloakY + 349), (cloakX+ 91), (cloakY +509), (cloakX+ 86), (cloakY +509));
fill(113, 99, 117, fadeOut);
triangle((cloakX + 62), (cloakY + 399), (cloakX +32), (cloakY +509), (cloakX + 99), (cloakY +509));
noStroke();
fill(39, 34, 40, fadeOut);
quad((legsX + 62), legsY + 399, (legsX + 69), legsY + 424, (legsX + 64), legsY + 519, (legsX + 59), legsY + 519);
quad((legsX + 62), legsY + 399, (legsX + 64), legsY + 424, (legsX + 39), legsY + 519, (legsX + 34), legsY + 519);
fill(94, 49, 15, fadeOut);
stroke(94, 49, 15, fadeOut);
rect((bodyX + 34), bodyY + 519, (bodyX + 39), bodyY + 529, 50);
rect((bodyX + 59), bodyY + 519, (bodyX + 64), bodyY + 529, 50);
triangle((bodyX + 54), bodyY + 329, (bodyX + 60), bodyY + 324, (bodyX + 49), bodyY + 319);
quad((bodyX + 55), bodyY + 329, (bodyX + 69), bodyY + 319, (bodyX + 64), bodyY + 339, (bodyX + 54), bodyY + 334);
stroke(20, 5, 20, fadeOut);
fill(20, 5, 20, fadeOut);
triangle((hairX + 50), hairY + 310, (hairX + 70), hairY + 320, (hairX + 61), hairY + 325);
quad((hairX + 50), hairY + 310, (hairX + 62), hairY + 325, (hairX + 50), hairY + 320, (hairX + 45), hairY + 315);
quad((hairX + 45), hairY + 315, (hairX + 50), hairY + 320, (hairX + 45), hairY + 332, (hairX + 40), hairY + 325);
quad((hairX + 50), hairY + 320, (hairX + 45), hairY + 332, (hairX + 55), hairY + 335, (hairX + 55), hairY + 330);
quad((hairX + 40), hairY + 325, (hairX + 47), hairY + 340, (hairX + 42), hairY + 345, (hairX + 39), hairY + 340);
triangle((hairX + 35), hairY + 345, (hairX + 40), hairY + 350, (hairX + 30), hairY + 360);
quad((hairX + 40), hairY + 350, (hairX + 38), hairY + 385, (hairX + 28), hairY + 391, (hairX + 30), hairY + 360);
quad((hairX + 28), hairY + 391, (hairX + 38), hairY + 385, (hairX + 25), hairY + 442, (hairX + 15), hairY + 428);
triangle((hairX + 15), hairY + 428, (hairX + 25), hairY + 442, (hairX + 16), hairY + 462);
triangle((hairX + 25), hairY + 442, (hairX + 25), hairY + 490, (hairX + 12), hairY + 472);
quad((hairTailX + 25), hairTailY + 470, (hairTailX + 25), hairTailY + 490, (hairTailX + 42), hairTailY + 505, (hairTailX + 47), hairTailY + 500);
quad((hairTailX + 47), hairTailY + 500, (hairTailX + 50), hairTailY + 502, (hairTailX + 40), hairTailY + 520, (hairTailX + 35), hairTailY + 512);
quad((hairTailX + 35), hairTailY + 512, (hairTailX + 40), hairTailY + 520, (hairTailX + 30), hairTailY + 522, (hairTailX + 22), hairTailY + 515);
triangle((hairTailX + 30), hairTailY + 522, (hairTailX + 22), hairTailY + 515, (hairTailX + 1), hairTailY + 530);
fill(191, 132, 22, fadeOut);
quad((beadX + 39), beadY + 340, (beadX + 42), beadY + 345, (beadX + 40), beadY + 350, (beadX + 35), beadY + 345);
noStroke();
fill(35, 0, 35, fadeOut-175);
ellipseMode(RADIUS);
ellipse((shadowX + 50)+(shadowY), shadowY + 575, shadowR, shadowY + 15);
//makes the nagashi follow the arrow keys as they're pressed.
if (keyPressed) {
if (cloakX <= 550) {
if (keyCode==RIGHT) {
cloakX = cloakX + 1;
legsX = legsX + 1;
bodyX = bodyX + 1;
hairX = hairX + 1;
hairTailX = hairTailX +1;
shadowX = shadowX +1;
beadX = beadX +1;
}
if (cloakX >= 0) {
if (keyCode==LEFT) {
cloakX = cloakX - 1;
legsX = legsX -1;
bodyX = bodyX -1;
hairX = hairX -1;
hairTailX = hairTailX - 1;
shadowX = shadowX -1;
beadX = beadX -1;
}
}
}
}
//makes the nagashi bob up and down
cloakY = cloakY + upAndDown/3;
legsY = legsY + upAndDown/3;
bodyY = bodyY + upAndDown/3;
hairY = hairY +upAndDown/3;
hairTailY = hairTailY + upAndDown/3;
beadY = beadY + upAndDown/3;
shadowR = shadowR -upAndDown/3;
highest = highest +upAndDown;
if (highest <= 0 ) {
upAndDown = +1;
}
if (highest>50 ) {
upAndDown = -1;
}
}
}class stars {
PVector starLocation = new PVector (0, 0); //PVector for the position of the star ellipses
float starSize = 2;
stars(float tempX, float tempY) {
starLocation.x = tempX;
starLocation.y = tempY;
}
void drawStars() {
fill(255, 255, 255, int(random(100, 225)));
ellipse((starLocation.x+5)*starSize, (starLocation.y)*starSize, 1, 1);
ellipse((starLocation.x+26)*starSize, (starLocation.y+7)*starSize, 1, 1);
ellipse((starLocation.x)*starSize, (starLocation.y+45)*starSize, 2, 2);
ellipse((starLocation.x+14)*starSize, (starLocation.y+18)*starSize, 1, 1);
ellipse((starLocation.x+38)*starSize, (starLocation.y+4)*starSize, 2, 2);
ellipse((starLocation.x+15)*starSize, (starLocation.y+20)*starSize, 2, 2);
}
}void drawSword() {
fill(35, 0, 35, fadeOut-175);
ellipse(1807.5+sideScroll, 575, 12, 4);
fill(184, 240, 232, fadeOut-100);
quad(1800+sideScroll, 575, 1815+sideScroll, 575, 1795+sideScroll, 425, 1780+sideScroll, 425);
stroke(184, 240, 232, fadeOut);
line(1785+sideScroll, 425, 1805+sideScroll, 574);
noStroke();
quad(1800+sideScroll, 575, 1805+sideScroll, 575, 1785+sideScroll, 425, 1780+sideScroll, 425);
fill(24, 28, 28, fadeOut);
rect(1775+sideScroll, 423, 1800+sideScroll, 426, 20);
quad(1783+sideScroll, 423, 1793+sideScroll, 423, 1790+sideScroll, 400, 1780+sideScroll, 400);
fill(165, 13, 34, fadeOut);
stroke(191, 132, 22, fadeOut-150);
triangle(1787+sideScroll, 398, 1780+sideScroll, 450, 1790+sideScroll, 453);
noStroke();
ellipse(1785+sideScroll, 395, 5, 5);
fill(255, 255, 255, fadeOut-150);
ellipse(1787+sideScroll, 397, 2, 2);
fill(255, 255, 255, fadeOut-125);
ellipse(1786+sideScroll, 396, 1, 1);
fill(22, 41, 48);
ellipse(1805+sideScroll, 574, 5, 3);
ellipse(1810+sideScroll, 577, 4, 4);
}