Current File : /home/jeshor13/11bsouth.com/DataBounce/sketch.js |
var bubbles = []
var school;
var price;
var temps = 0;
var x = 0;
var y = 0;
function setup() {
createCanvas(800, 600);
var url = 'http://api.openweathermap.org/data/2.5/weather?APPID=c0c46c300b1e179483ed0e03ba4c77be&q=NewYork,USA'
loadJSON(url, drawWeather);
}
function draw() {
background(0);
text(x,20,20)
text(y,20,35)
for (var i = 0; i < bubbles.length; i++) {
bubbles[i].update();
bubbles[i].display();
if (bubbles[i].x > width * 0.95 || bubbles[i].x < width * 0.05) {
bubbles[i].changeDirectionX();
// bubbles[i].changeDirectionY();
// bubbles[j].changeDirectionX();
//bubbles[j].changeDirectionY();
}
if (bubbles[i].y > height * 0.95 || bubbles[i].y < height * 0.05) {
//bubbles[i].changeDirectionX();
bubbles[i].changeDirectionY();
//bubbles[j].changeDirectionX();
// bubbles[j].changeDirectionY();
}
for (var j = 0; j < bubbles.length; j++) {
if (i != j && bubbles[i].intersects(bubbles[j])) {
var entwined = [bubbles[i].changeDirectionX(), bubbles[i].changeDirectionY(), bubbles[j].changeDirectionX(), bubbles[j].changeDirectionY()]
// bubbles[i].changeColor();
// bubbles[i].changeDirectionY();
//bubbles[j].changeColor();
// bubbles[j].changeDirectionY();
entwined[random(0, 3)]
}
}
}
}
function mousePressed() {
for (var k = 0; k < x; k++) {
bubbles[k] = new Bubble(random(width * 0.05, width * 0.90), random(height * 0.05, height* 0.95));
}
}
function drawWeather(weather) {
// Get the loaded JSON data
console.log(weather); // inspect the weather JSON
temps = weather.main.temp; // get the main.humidity out of the loaded JSON
speed = weather.wind.speed;// inspect the humidity in the console
temps = ceil(temps)
x = int((temps*9/5) - 459.67)
y = (speed)
}