float x;
float y;
float dy;
float t;
float houstonX;
void setup() {
size(250, 250);
frameRate(10);
x = width/2;
y = 200;
dy = -1;
t = 0;
houstonX = 0;
}
void drawRocket(float x, float y, float scale) {
// Body:
fill(255, 255, 0);
stroke(0);
rect(x - 25, y - 50, 50, 100);
// Nose cone:
triangle(x - 25, y - 50, // left
x, y - 50 - 75, // center
x + 25, y - 50); // right
// Left fin:
triangle(x - 25, y,
x - 25, y + 50,
x - 50, y + 50);
// Right fin:
triangle(x + 25, y,
x + 25, y + 50,
x + 50, y + 50);
}
void houston(float x, float y) {
fill(0);
stroke(0);
float w = 50;
rect(x, y - 10, w, 10);
rect(x + w, y - 30, w, 30);
rect(x + w * 2, y - 20, w, 20);
rect(x + w * 3, y - 5, w, 5);
rect(x + w * 4, y - 70, w, 70);
rect(x + w * 5, y - 20, w, 20);
rect(x + w * 6, y - 5, w, 5);
rect(x + w * 7, y - 40, w, 40);
rect(x + w * 8, y - 25, w, 25);
rect(x + w * 9, y - 5, w, 5);
rect(x + w * 10, y - 40, w, 40);
rect(x + w * 11, y - 20, w, 20);
rect(x + w * 12, y - 15, w, 15);
rect(x + w * 13, y - 60, w, 60);
rect(x + w * 14, y - 20, w, 20);
}
void speak(String t, float x, float y) {
float h = 30;
float w = 120;
float q = 10;
fill(255);
stroke(0);
triangle(x, y, x + q, y - h, x + 2 * q, y - h);
rect(x, y - 2 * h, w, h);
// tiny box to cover line:
fill(255);
stroke(255);
rect(x + q, y - h - 2, q - 2, 2);
fill(0);
text(t, x + q, y - h - q);
}
void kevin(float x, float y) {
fill(20, 60, 120);
stroke(20, 60, 120);
ellipse(x, y, 10, 20);
}
void draw() {
background(0, 0, 255);
if (t < 10) {
houstonX = houstonX - 5;
houston(houstonX, height/2);
kevin(30, height/2 + 20);
//drawRocket(x, y, 1);
// wait for blast off
//speak("Countdown ..." + int(10 - t), x, y);
} else if (t < 20) {
houston(houstonX, height/2);
kevin(30, height/2 + 20);
speak("Wanna see a rocket?", 35, height/2 + 10);
//drawRocket(x, y, 1);
//speak("Wheeeeee!", x, y);
} else if (t < 30) {
houston(houstonX, height/2);
drawRocket(x, y, 1);
kevin(30, height/2 + 20);
} else if (t < 40) {
y = y + dy;
dy = dy - 0.1;
houston(houstonX, height/2);
drawRocket(x, y, 1);
kevin(30, height/2 + 20);
speak("Wait for me!", 35, height/2 + 10);
} else {
setup(); // sets t back to 0
}
fill(255); // white text
text("Time: " + int(t), 0, 200);
t = t + .1;
}