xxxxxxxxxx
118
var facts = ['At the rate our climate is changing, the world will soon be warmer than at any time in the last 10,000 years.','Climate changes will alter natural vegetation, wildlife habitats, crop growing season, and distribution of pests and diseases.', 'About 30 new infectious disease have emerged in the past 20 years.', 'Climate change could drive as many as 1 in 6 animals and plant species to extinction.', 'Each year of the 21st century is among the hottest since 1880.', 'According to the WWF, global warming could kill off polar bears in the next 20 years.', 'Just a one-yard rise in sea level is enough to displace over 100 million people.', 'Of the land in California, 99.84 percent is experiencing drought.', 'The world lost about 16 percent of all coral reefs in 1998, the second hottest year on record','Climate change costs the U.S. over $100 billion each year.']
var w = 100
var h = 100
var angle =0.0;
var jitter = 0.0;
var font;
var a = 255
var b = 0
var b1 = 97
var b2 = 35
var b3 = 29
var index=0
var f1 = 20
var f2 = 50
var randomFacts = facts[Math.floor(Math.random()*facts.length)];
var randomFacts2= facts[Math.floor(Math.random()*facts.length)];
var randomFacts3= facts[Math.floor(Math.random()*facts.length)];
//^vars not being used due to index
function preload() {
font = loadFont("font.ttf");
}
function setup() {
createCanvas(1000, 400);
earth=loadImage("earth.png");
imageMode(CENTER);
}
function draw() {
background(b1,b2,b3);
fill(255);
ellipse(width/2,height/2,100,100);
textFont(font);
textSize(12);
fill(255,0,0);
text("Save the Earth!",width/2-40,height/2);
fill(0,200,0);
textSize(20);
textFont("Cambria");
text("GLOBAL WARMING 'FUN' FACTS: 1-10!",20,20)
textSize(15);
if ((keyIsPressed==true)&&(key=='1')){
fill(0);
text(facts[index],f1,f2);
}
if ((keyIsPressed==true)&&(key=='2')){
fill(0);
text(facts[index+1],f1,f2);
}
if ((keyIsPressed==true)&&(key=='3')){
fill(0);
text(facts[index+2],f1,f2);
}
if ((keyIsPressed==true)&&(key=='4')){
fill(0);
text(facts[index+3],f1,f2);
}
if ((keyIsPressed==true)&&(key=='5')){
fill(0);
text(facts[index+4],f1,f2);
}
if ((keyIsPressed==true)&&(key=='6')){
fill(0);
text(facts[index+5],f1,f2);
}
if ((keyIsPressed==true)&&(key=='7')){
fill(0);
text(facts[index+6],f1,f2);
}
if ((keyIsPressed==true)&&(key=='8')){
fill(0);
text(facts[index+7],f1,f2);
}
if ((keyIsPressed==true)&&(key=='9')){
fill(0);
text(facts[index+8],f1,f2);
}
if ((keyIsPressed==true)&&(key=='0')){
fill(0);
text(facts[index+9],f1,f2);
}
if (second() % 2 == 0) {
jitter = random(0.1);
}
angle = angle + jitter;
translate(width/2, height/2);
//apply the final rotation
rotate(angle);
tint(a,b,0);
image(earth,75,100,w,h);
fill(0);
}
function mousePressed() {
var d= dist(mouseX,mouseY, width/2,height/2);
if(d<100) {
a = a-10
b=b+20
b1=b1-20
b2=b2+9
b3=b3+30
}
}