//-------------------------------------------------------------- void ofApp::setup(){ // ofEnableBlendMode(OF_BLENDMODE_ADD); // ofEnableBlendMode(OF_BLENDMODE_SCREEN); /*---------- DATA ----------*/ // Comment this out... ------------------------- ofBuffer file = ofBufferFromFile("api_key.txt"); string apiKey = file; // --------------------------------------------- // ...and replace the apiKey variable with your own api key: -------------------------------- string apiUrl = "http://api.wunderground.com/api/" + apiKey + "/conditions/forecast10day/q/"; // ------------------------------------------------------------------------------------------ string citiesUrls[NUM_CITIES] = {"NY/New_York.json", "CA/san_francisco.json", "China/shanghai.json", "Mexico/mexico_city.json", "Brazil/sao_paulo.json"}; string citiesNames[NUM_CITIES] = {"New York", "San Francisco","Shanghai", "Mexico City", "Sao Paulo"}; // Actually loading the data by passing an url to the City object for (int i = 0; i < NUM_CITIES; i++) { City thisCity; thisCity.setup(apiUrl + citiesUrls[i], citiesNames[i], i, NUM_CITIES); allCities.push_back(thisCity); } // Getting highest and lowest // We need to know the numbers range! float highestTemp = -1000; // Anything will be higher than this, so we don't risk setting up a value float lowestTemp = 1000; // In this case, anything will be lower for(int i = 0; i < allCities.size(); i++){ // HIGH for(int j = 0; j < allCities[i].highs.size(); j++){ if(allCities[i].highs[j] > highestTemp){ highestTemp = allCities[i].highs[j]; } } // LOW for(int j = 0; j < allCities[i].lows.size(); j++){ if(allCities[i].lows[j] < lowestTemp){ lowestTemp = allCities[i].lows[j]; } } } cout << "The highest temperature is: " << highestTemp << endl; cout << "The lowest temperature is: " << lowestTemp << endl; /*--------- LAYOUT ---------*/ ofPoint chartSize = ofPoint(ofGetWidth() * 0.7, ofGetHeight() * 0.7); ofPoint chartPos = ofPoint(ofGetWidth() * 0.15, ofGetHeight() * 0.15); for(int i = 0; i < allCities.size(); i++){ allCities[i].setLayout(chartPos, chartSize, highestTemp, lowestTemp); } }
void testApp::setup(){ ofSetFrameRate(60); ofSetVerticalSync(true); ofBackground(0); ofEnableAlphaBlending(); ofSetCircleResolution(33); ofDisableArbTex(); startup.loadSound("start.wav"); launch.loadSound("launch.wav"); explode.loadSound("explode.wav"); empty.loadSound("empty.wav"); city.loadImage("city.png"); city.getTextureReference().setTextureMinMagFilter(GL_NEAREST, GL_NEAREST); silo.loadImage("silo.png"); silo.getTextureReference().setTextureMinMagFilter(GL_NEAREST, GL_NEAREST); bg.loadImage("bg.png"); bg.getTextureReference().setTextureMinMagFilter(GL_NEAREST, GL_NEAREST); logo.loadImage("logo.png"); logo.getTextureReference().setTextureMinMagFilter(GL_NEAREST, GL_NEAREST); startButton.loadImage("startButton.png"); startButton.getTextureReference().setTextureMinMagFilter(GL_NEAREST, GL_NEAREST); font.loadFont("ARCADE_N.TTF", 12, false, false); int numCities = NUM_CITIES; for(int i = 0; i < NUM_CITIES/2; i++){ City o; o.setup(&city); o.color = CITY_COLOR; o.position.y = ofGetHeight() - city.height * 2.0 - ofRandom(10); o.position.x = ofGetWidth() * 0.19 + ofGetWidth() * 0.55 * i / (numCities - 1) - city.width * 0.5; cities.push_back(o); } for(int i = 0; i < NUM_CITIES/2; i++){ City o; o.setup(&city); o.color = CITY_COLOR; o.position.y = ofGetHeight() - city.height * 2.0 - ofRandom(10); o.position.x = ofGetWidth() * (0.5 + 0.19/2) + ofGetWidth() * 0.55 * i / (numCities - 1) - city.width * 0.5; cities.push_back(o); } Silo *s = new Silo(); s->setup(&silo); s->color = SILO_COLOR; s->position = SILO_LEFT - ofVec2f(silo.getWidth() * 0.5, silo.getHeight() * 0.5); s->setMissileSpeed(GOOD_MISSILE_SPEED); silos.push_back(s); s = new Silo(); s->setup(&silo); s->color = SILO_COLOR; s->setMissileSpeed(GOOD_MISSILE_SPEED * 2); s->position = SILO_MID - ofVec2f(silo.getWidth() * 0.5, silo.getHeight() * 0.5); silos.push_back(s); s = new Silo(); s->setup(&silo); s->setMissileSpeed(GOOD_MISSILE_SPEED); s->color = SILO_COLOR; s->position = SILO_RIGHT - ofVec2f(silo.getWidth() * 0.5, silo.getHeight() * 0.5); silos.push_back(s); // explosions MEDIA_LOAD_TEXTURE("smoke2.png", TEX_SMOKE); MEDIA_GET_TEXURE(TEX_SMOKE)->setTextureMinMagFilter(GL_NEAREST, GL_NEAREST); MEDIA_LOAD_TEXTURE("fire.png", TEX_FIRE); MEDIA_GET_TEXURE(TEX_FIRE)->setTextureMinMagFilter(GL_NEAREST, GL_NEAREST); MEDIA_LOAD_TEXTURE("explosion.png", TEX_EXPLOSION); MEDIA_GET_TEXURE(TEX_EXPLOSION)->setTextureMinMagFilter(GL_NEAREST, GL_NEAREST); e.setup( MEDIA_GET_TEXURE(TEX_SMOKE), MEDIA_GET_TEXURE(TEX_FIRE), MEDIA_GET_TEXURE(TEX_EXPLOSION) ); e.setSmokeProperties( 5, //random spawn pos offset from debris ofVec2f(0,-50), //smoke particles speed in pix / sec ofVec2f(150,0), //smoke particles acc in pix / sec 0.9 //life in seconds ); strength = 400; numP = 10; friction = 0.94; life = 0.9; offset = 0; spawnOffset = 5; smokeLife = 0.9; gravity = 200; /////////// #ifdef USE_REMOTE_CAMERA remoteCam.initGrabber(640,480); remoteCam.start(); remoteCam.setRequestedImageType(OF_IMAGE_GRAYSCALE); remoteCam.setRequestedCompressionQuality( 90 );//jpeg, [0..100] #endif laser.setup(ofRectangle(0,0, ofGetWidth(), ofGetHeight()), this, 640, 480, OF_IMAGE_GRAYSCALE); state = START_SCREEN; //graffiti currentLine = -1; ofSetWindowPosition(-800,0); ofSetFullscreen(true); }