/* built with Studio Sketchpad:
* https://sketchpad.cc
*
* observe the evolution of this sketch:
* https://studio.sketchpad.cc/sp/pad/view/ro.TY7N3JL94Dr/rev.5732
*
* authors:
* Benjamin Y
* license (unless otherwise specified):
* creative commons attribution-share alike 3.0 license.
* https://creativecommons.org/licenses/by-sa/3.0/
*/
/*
'End of the Qin Dynasty: Race to Xianyang' is
a historical moment when LiouBang ended the
ambitious Qin Dynasty.
*/
/* CREATED USING CHROME */
chuY = 350;
hanY = 350;
PImage chuHanXiangZheng = loadImage("/static/uploaded_resources/p.18937/chuHanXiangZheng.png");
PImage hanExtent = loadImage("/static/uploaded_resources/p.18937/han2.png");
PFont fontMono = createFont('Courier New');
PFont fontSans = createFont('Bookman Old Style');
textFont(fontSans);
textSize(14);
stop = 0;
int abs(int num) {
if (num >= 0) {
return num;
}
return -num;
}
void draw() {
strokeWeight(1);
size(400, 400);
background(0, 128, 0);
fill(255, 128, 0);
rect(125, 0, 150, 50, 50);
fill(51, 128, 0);
noStroke();
rect(0, 200, 400, 200);
stroke(255, 255, 255);
fill(128, 255, 128);
beginShape();
vertex(100, 100);
vertex(130, 200);
vertex(120, 200);
vertex(120, 300);
vertex(80, 300);
vertex(80, 200);
vertex(70, 200);
endShape(CLOSE);
fill(255, 255, 255);
line(150, 350, 250, 350);
line(200, chuY, 200, hanY);
text('chu', 125, 350);
text('han', 225, 350);
text('XianYang \n (Xian)', 175, 30);
//text('cm = km', 0, 30);
text('Chu', 200, 250);
text('Qin', 200, 150);
text('Go To Xianyang!', 150, 370);
/* COMPARE WIDGET */
noStroke();
if(chuY < hanY - 20) {
fill(0, 204, 204);
rect(0, 0, 75, 75);
fill(255, 51, 51);
text('NO!', 0, 60);
} else if(chuY < hanY - 10) {
fill(0, 153, 204);
rect(0, 0, 75, 75);
fill(255, 102, 51);
text('NO!', 0, 60);
} else if(chuY < hanY) {
fill(0, 102, 204);
rect(0, 0, 75, 75);
fill(255, 153, 51);
} else if(chuY < hanY+10) {
fill(33, 33, 231);
rect(0, 0, 75, 75);
fill(222, 222, 24);
} else if(chuY < hanY+20) {
fill(51, 0, 231);
rect(0, 0, 75, 75);
fill(204, 255, 24);
} else if(chuY < hanY+25) {
fill(204, 51, 204);
rect(0, 0, 75, 75);
fill(51, 204, 51);
text('WOW!', 0, 60);
} else {
fill(204, 33, 204);
rect(0, 0, 75, 75);
fill(51, 222, 51);
text('WOW!', 0, 60);
}
text('GO!', 45, 60);
stroke(255);
line(0, 75/2, 75, 75/2);
textSize(20);
if (abs(chuY-hanY) < 100) {
text(abs(chuY-hanY), 0, 30);
}
textSize(15);
noStroke();
strokeWeight(1);
if(chuY > hanY){
ellipse(30, 380, (chuY-hanY)/2, (chuY-hanY)/2);
noFill();
//stroke(255);
arc(30, 380, (chuY-hanY)/2 + 10, (chuY-hanY)/2 + 10, 0, TWO_PI);
}
if(chuY < hanY){
ellipse(30, 380, (hanY-chuY)/2, (hanY-chuY)/2);
noFill();
//stroke(255);
arc(30, 380, (hanY-chuY)/2 + 10, (hanY-chuY)/2 + 10, 0, TWO_PI);
}
if(chuY < 200 || hanY < 200){
fill();
fill(222, 222, 24);
ellipse(10, 380, 15, 15);
}
fill(255);
stroke(255);
textFont(fontMono);
text('E R\nN A\nD C\n E\nO \nF F\n O\nT R\nH \nE \n X\nQ I\nI A\nN N\n Y\nD A\nY N\nN G\nA\nS\nT\nY\n', 0, 100);
text('E R\nN A\nD C\n E\nO \nF F\n O\nT R\nH \nE \n X\nQ I\nI A\nN N\n Y\nD A\nY N\nN G\nA\nS\nT\nY\n', 1, 101);
textFont(fontSans);
text('2\n0\n6\n \nB\nC\nE', 350, 100);
text('2\n0\n6\n \nB\nC\nE', 351, 101);
textSize(15);
//img
image(chuHanXiangZheng, 300, 300, 100, 100);
image(hanExtent, 300, 200, 100, 100);
line(300, 300, 400, 300);
line(300, 200, 300, 400);
fill(255, 51, 51);
ellipse(150, 30, 25, 25);
ellipse(150, chuY, 10, 10);
//text('Chu', 325, 75-chuPY/5);
text('Chu:\nXiangYu', 80, chuY);
fill(51, 222, 51);
ellipse(250, 30, 25, 25);
ellipse(250, hanY, 10, 10);
//text('Han', 360, 75-chuPY/5);
text('Han:\nLiouBang', 260, hanY);
fill(0, 255, 128);
textSize(14);
fill(255, 255, 255);
stroke(255, 51, 51);
chuPY = chuY-30;
line(350, 75, 350, 75-chuPY/5);
line(325, 75-chuPY/5, 360, 75-chuPY/5);
line(130, chuY, 270, chuY);
line(150, 0, 150, 400);
stroke(51, 222, 51);
hanPY = hanY-30;
line(375, 75, 375, 75-hanPY/5);
line(325, 75-hanPY/5, 385, 75-hanPY/5);
line(130, hanY, 270, hanY);
line(250, 0, 250, 400);
stroke(255);
line(325, 75, 400, 75);
line(325, 0, 325, 75);
noStroke();
/*fill(51, 222, 51);
ellipse(10, 380, 5, 5);
fill(222, 222, 24);
ellipse(20, 380, 4, 4);
fill(255, 51, 51);
ellipse(30, 380, 5, 5);*/
strokeWeight(5);
fill(0, 128, 255); // Yangtze River
stroke(0, 128, 255);
line(0, 200, 400, 200);
text('Yangtze', 100, 190);
strokeWeight(1);
stroke(255);
fill(255);
stroke(255);
//text(' [_]', 10, 380);
if((chuY <= 30)||(hanY <= 30)){
strokeWeight(25);
if(chuY <= 30){
text('XIANGYU WON!', 200, 200);
return;
}else{
text('LIOUBANG WON!', 200, 200);
return;
}
}
if(mouseX < hanY + 1){
hanY -= random(3.2/2);
}else{
if(mouseY > hanY){
hanY -= random(0.5);
}else{
hanY -= random(2.5/2);
}
}
chuY -= random(random(2.5/2, 1.5));
}