backgr = loadImage('Tausta6.jpg');
forest = loadImage('forest.png');
createCanvas(windowWidth, windowHeight);
border_right = windowWidth -80;
colors[0] = random(50,255);
colors[1] = random(50,200);
colors[2] = random(50,200);
fill(colors[0],colors[1],colors[2]);
fill(255,random(140,255),0);
if (abs(speed_y) < 30000){
triangle(10,29, 20,45+speed_y*(-0.1), 0,45+speed_y*(-0.1));
triangle(10,29, 20,45+3000, 0,45+3000);
if (loc_y < windowHeight/2){
image(backgr, border_left, windowHeight*1.5-loc_y, border_right, -windowHeight-loc_y-400000);
image(forest, border_left, windowHeight*1.5-loc_y, border_right, windowHeight-loc_y);
image(backgr, border_left, windowHeight, border_right, -windowHeight-400000);
image(forest, border_left, windowHeight, border_right, 0);
ball_height = round(abs(loc_y - bottom)/8)
text("Vertical speed: " + round(-1*(speed_y),0) + " m/s", 100, 50);
text("Height: " + ball_height + " m", 100, 100);
if (abs(speed_y) < 3000000){
text("Vertical speed: " + round(-1*(speed_y),0) + " m/s", 100, 50);
text("Vertical speed: " + round(-1*(speed_y/1000),1) + " km/s", 100, 65);
text("Height: " + ball_height + " m", 100, 100);
text("Height: " + round(ball_height/1000,1) + " km", 100, 115);
text("Vertical speed: " + round(-1*(speed_y),0) + " m/s", 100, 50);
text("Vertical speed: " + round(-1*(speed_y/1000),1) + " km/s", 100, 65);
text("Vertical speed: " + round(-1*(speed_y/300000000*100),2) + " % of light speed", 100, 80);
text("Height: " + round(ball_height/1000,1) + " km", 100, 100);
text("Height: " + round(ball_height/150000000000,2) + " times the distance between earth and sun (au)", 100, 115);
if (ball_height < pow(10,10)){
text("Height: 0.000000 light-years (ly)", 100, 130);
text("Height: " + round(ball_height/(9.46*pow(10,15)),6) + " light-years (ly)", 100, 130);
text("Over 'Zulu', the tallest giraffe ~5.8 m", 100, 180);
else{text("-----------------------------", 100, 180);}
text("Over the tallest rubber duck 20 m", 100, 200);
else{text("-----------------------------", 100, 200);}
text("Over the tallest tree 115 m", 100, 220);
else{text("-----------------------------", 100, 220);}
text("Over Statue of Unity 182 m", 100, 240);
else{text("-----------------------------", 100, 240);}
text("Over Hollola TV mast 327 m", 100, 260);
else{text("-----------------------------", 100, 260);}
text("Over GRES-2 Power Station Chimney 419 m", 100, 280);
else{text("-----------------------------", 100, 280);}
text("Over Burj Khalifa 828 m", 100, 300);
else{text("-----------------------------", 100, 300);}
text("Over Angel Falls (waterfall) 979 m", 100, 320);
else{text("-----------------------------", 100, 320);}
text("Balls in this height might need a jetpack: hold 'R'", windowWidth/2-200, windowHeight*0.1);
if (abs(speed_y) > 3000){
text("Hold also 'P' for more power", windowWidth/2-200, windowHeight*0.1+15);
text("Over the town of Puno in Peru 5,1 km", 100, 340);
else{text("-----------------------------", 100, 340);}
text("Over Mt. Everest 8,8 km", 100, 360);
else{text("-----------------------------", 100, 360);}
if (ball_height > 11000){
text("Over Challanger deep upside down 11 km", 100, 380);
else{text("-----------------------------", 100, 380);}
if (ball_height > 100000){
text("Over Kármán line 100 km, welcome to outer space.", 100, 400);
else{text("-----------------------------", 100, 400);}
if (ball_height > 408000){
text("Over the altitude of International Space station 408 km", 100, 420);
else{text("-----------------------------", 100, 420);}
if (ball_height > 20180000){
text("Over the altitude of GPS orbital height 20 180 km", 100, 440);
else{text("-----------------------------", 100, 440);}
if (ball_height > 384400000){
text("You just passed the moon at 384 400 km", 100, 460);
else{text("-----------------------------", 100, 460);}
if (ball_height > 22.2*pow(10, 12)){
text("You just passed Voyager 1 satellite 148 au", 100, 480);
else{text("-----------------------------", 100, 480);}
if (ball_height > 30*pow(10,12)){
text("Goodbye our Solar System 200 au", 100, 500);
else{text("-----------------------------", 100, 500);}
if (ball_height > 4.36*9.46*pow(10,15)){
text("You passed the Alfa Centauri 4.36 ly", 100, 520);
else{text("-----------------------------", 100, 520);}
if (ball_height > 71754*9.46*pow(10,15)){
text("You are leaving the Milky Way 72000 ly", 100, 540);
else{text("-----------------------------", 100, 540);}
if (ball_height > 2.5*pow(10,6)*9.46*pow(10,15)){
text("Welcome to Andromeda Galaxy 2.5 Mly", 100, 560);
else{text("-----------------------------", 100, 560);}
if (ball_height > 46.5*pow(10,9)*9.46*pow(10,15)){
text("You have arrived to the edge of the universe which is observable from earth 46.5 Bly,", 100, 580);
text("Here's a cookie for you: ֍", 100, 600);
else{text("-----------------------------", 100, 580);}
if (keyIsDown(LEFT_ARROW)) {
acceleration_x = -acceleration;
else if (keyIsDown(RIGHT_ARROW)){
acceleration_x = acceleration;
if (keyIsDown(UP_ARROW)) {
bounciness = bounciness0;
if (speed_x > max_speed){
else if (speed_x < -max_speed){
speed_x = (speed_x + acceleration_x) * 0.95;
if (loc_x < border_left) {
speed_x = speed_x * -1.2;
else if (loc_x > border_right-20){
speed_x = speed_x * -1.2;
speed_y = speed_y + gravity
if ( abs(speed_y) < 0.5 && loc_y >= bottom-5 && bounces > 6) {
speed_y = abs(speed_y) * bounciness;
if (loc_y < windowHeight/2){
translate(loc_x,windowHeight/2);