//--------------------------------------------------------------
void ofApp::keyPressed(int key)
{
	switch(key)
	{
	// If pressed F change debug mode
	case 'f':
	case 'F':
		debug = !debug;
		break;	
	case OF_KEY_LEFT_CONTROL:
		if (getSpaceShip(1)){
			getSpaceShip(1)->createBullets();
			shot.play();
		}
		break;
	case OF_KEY_RIGHT_CONTROL:
		if (getSpaceShip(2)){
			getSpaceShip(2)->createBullets();
			shot.play();
		}
		break;
	case OF_KEY_ESC:
		music.unloadSound();
		explosion.unloadSound();
		shot.unloadSound();
		exit();
		break;
	}	
}
Exemplo n.º 2
0
void ofApp::playSoundAtVolumeSpeed( 
  ofSoundPlayer& SChgSize, 
  float Vol, 
  float Spd )
{
  SChgSize.setVolume(Vol);
  SChgSize.setSpeed(Spd);
  SChgSize.play();
}
Exemplo n.º 3
0
//--------------------------------------------------------------
void ofApp::update() {
    ofBackground(255);

    if (werk)
    {
        bal.update();

        if (keyup){
            player.up();
        }

        else if (keydown){
            player.down();
        }
    }

    if(bal.x < 0 ){
        bal.x = 0;
        werk = false;
    }

    if (bal.x < player.x + (player.width))
    {
        if (player.y > player.y - (player.height/2) && bal.y < player.y + (player.height /  2))

        {
            bal.speedX = - bal.speedX;
            score ++;
            puts("score");
            pling.play();

        }
    }

}
Exemplo n.º 4
0
	Mover(){
		//hitsound
		hitsound.loadSound("HitSound.wav");
		maxspeed= ofRandom(1,2); //maxspeed and different for aal circles
		accel = ofPoint(-.001, .01);
		location = ofPoint(ofRandom(ofGetWidth()), ofRandom(ofGetHeight()));  //random start of the circle
		velocity = ofPoint(ofRandom(-2.0,2.0), ofRandom(-2.0,2.0)); // random speed

		ofSetColor(100, ofRandom(255),100);
	}
Exemplo n.º 5
0
void Bubble::update() {
    x += xVel;
    y += yVel;
    
    if ((x > ofGetWindowWidth()) || (x < 0)) {
        xVel *= (-1);
        sound.play();
    }
    if ((y > ofGetWindowHeight()) || (y < 0)) {
        yVel *= (-1);
        sound.play();
    }
    
    //collision with rectangle
    
//    for (<#initialization#>; <#condition#>; <#increment#>) {
//        <#statements#>
//    }
    
    
}
Exemplo n.º 6
0
//--------------------------------------------------------------
void ofApp::setup() {

    score = 0;
    keyup = false;
    keydown = false;
    bal.setup();
    player.setup();
    pling.loadSound("pling.wav");
    werk = true;


}
Exemplo n.º 7
0
//--------------------------------------------------------------
void testApp::keyPressed(int key){
    cout << "fps: " << ofToString(ofGetFrameRate()) << endl;
    cout << "frame: " << ofToString(ofGetFrameNum()) << endl;
    
    if (key == 'f')
        drawFBO = !drawFBO;
    if (key == 'r')
        autoRotate = !autoRotate;
    if (key == 'p')
        player.play();
    if (key == 'e')
        drawEQ = !drawEQ;
}
void ofApp::splitAsteroid(int which)
{
	int asteroidShape = 0;

	if(asteroids[which]->getSize() > 20) 
	{
		for(int i = 0; i < (asteroids[which]->getSize()/40)+1; i++) 
		{
			asteroidShape = ofRandom(asteroidsDefinitions.size());

			Asteroid* newAsteroid = new Asteroid();
			newAsteroid->setup(asteroidsDefinitions.at(asteroidShape), asteroids[which]->getSize()/2, asteroids[which]->getSpeed(), asteroids[which]->getRotation(), asteroids[which]->getPosition(), ofPoint(-(ofRandom(-1, 1)), ofRandom(-1, 1)));
			asteroids.push_back(newAsteroid);
		}
	} 

	asteroids.erase(asteroids.begin() + which);

	if(asteroids.size() == 0) 
	{
		generateAsteroids(ofRandom(4,6));
	}

	//Play sound explosion
	explosion.play();

	//GUI Data Update
	if(getSpaceShip(1)){
		Player1Lifes = ofToString (getSpaceShip(1)->getLifes());
		Player1Score = ofToString (getSpaceShip(1)->getPoints());
		switch(getSpaceShip(1)->getLifes())	{
		case 0: serialConnection.writeByte('s'); break;
		case 1: serialConnection.writeByte('o'); break;
		case 2: serialConnection.writeByte('w'); break;
		case 3: serialConnection.writeByte('h'); break;
		}
	}
	if(getSpaceShip(2)){
		Player2Lifes = ofToString (getSpaceShip(2)->getLifes());
		Player2Score = ofToString (getSpaceShip(2)->getPoints());
		switch(getSpaceShip(2)->getLifes())	{
		case 0: serialConnection.writeByte('f'); break;
		case 1: serialConnection.writeByte('u'); break;
		case 2: serialConnection.writeByte('d'); break;
		case 3: serialConnection.writeByte('t'); break;
		}
	}
}
Exemplo n.º 9
0
void Bubble::setup(int _x, int _y) {
    ofEnableSmoothing();
    ofEnableAlphaBlending();
    
    ofSetFrameRate(60);
    
    x = _x;
    y = _y;
    bubbleSize = ofRandom(10,50);
    
    color = ofColor(ofRandom(255),ofRandom(255),ofRandom(255));
    
    sound.loadSound("sounds/Mario.mp3");
    
    
}
Exemplo n.º 10
0
	void update(){

		Hands= ofPoint(x,y); //location of the hands in the air  ( ir sensors)
		dir= ofPoint(Hands - location); 

		dir.normalize();
		dir *=0.01;
		accel= dir;

		velocity += accel; //speed
		location += velocity; // where is + the movement speed
		velocity.limit(maxspeed); //verctor doesnt get bigger then 3

		//collision target
		if(ofDist(Target.x,Target.y, location.x, location.y)<rectSize){
			points ++;
			Target=ofPoint(ofRandom(20,ofGetWidth()-20), ofRandom(20,ofGetHeight()-20));
			hitsound.play();
		}

	}
Exemplo n.º 11
0
void setup() {
	ofSetVerticalSync(true);
	ofSetWindowShape(1024, 768);

	// we add this listener before setting up so the initial circle resolution is correct
	circleResolution.addListener(this, &ofApp::circleResolutionChanged);
	ringButton.addListener(this,&ofApp::ringButtonPressed);

	gui.setup(); // most of the time you don't need a name
	gui.add(filled.setup("fill", true));
	gui.add(radius.setup( "radius", 140, 10, 300 ));
	gui.add(center.setup("center",ofVec2f(ofGetWidth()*.5,ofGetHeight()*.5),ofVec2f(0,0),ofVec2f(ofGetWidth(),ofGetHeight())));
	gui.add(color.setup("color",ofColor(100,100,140),ofColor(0,0),ofColor(255,255)));
	gui.add(circleResolution.setup("circle res", 5, 3, 90));
	gui.add(twoCircles.setup("two circles"));
	gui.add(ringButton.setup("ring"));
	gui.add(screenSize.setup("screen size", ""));

	bHide = true;

	ring.loadSound("ring.wav");
}
Exemplo n.º 12
0
void ringButtonPressed()
{
	ring.play();
}
//--------------------------------------------------------------
void ofApp::setup()
{
	// Set framerate to 60 FPS
	ofSetFrameRate(60);

	// Load Asteroids from XML
	loadAsteroids();

	// Create Asteroids
	generateAsteroids(4);

	// TODO
	// Setup the following elements:
	// - players
	// - listeners? (depends on how you handle messages between entities)

	noPlayers = 2;
	SpaceShip* player;	
	for (int i = 0; i < noPlayers; i++) {
		player = new SpaceShip(i+1);
		players.push_back(player);
	}

	if (noPlayers == 1) {
		player = new SpaceShip(2, true);
		players.push_back(player);
	}

	//??? ofAddListener(); ???
	//ofAddListener(SpaceShip::pressedKeyEvent, this, &ofApp::keyPressed);

	// General logic
	ofBackground(0); // Set background to black

	// Debug
	debug = false;

	//Load Sounds

	//Explosions
	explosion.loadSound("Explode.aif");
	explosion.setSpeed(1.5f);

	//Music
	music.loadSound("Gradius.mid");
	music.setLoop(true); //Sound will loop
	//music.play();

	//SpaceShip Shots
	shot.loadSound("missile_fire.wav");
	shot.setSpeed(4.0f);
	shot.setVolume(0.3f);
	
	ofxLabel line;

	//GUI Setup
	gui.setup(); // most of the time you don't need a name	
	gui.add(Player1Lifes.setup("Player1 Lifes", "3"));
	gui.add(Player2Lifes.setup("Player2 Lifes", "3"));
	gui.add(Player1Score.setup("Player1 Score", "0"));
	gui.add(Player2Score.setup("Player2 Score", "0"));

}
Exemplo n.º 14
0
//--------------------------------------------------------------
void testApp::setup(){
    
    ofBackground(0);
    ofSetFrameRate(30);
    ofEnableAlphaBlending();
    //    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
    //    glEnable(GL_DEPTH_TEST);
    glPointSize(1.0);
    drawFBO = false;
    autoRotate = true;
    drawEQ = false;
    
    //not really needed
    //    glEnable(GL_ALPHA_TEST);
    //    glAlphaFunc(GL_GREATER, 0.10f);
    
    //generate the mesh points
    buildSphereMesh(rad, res, vm);
    cout << "nverts: " << vm.getNumVertices() << endl;
    cout << "arb: " << ofGetUsingArbTex() << ", norm: " << ofGetUsingNormalizedTexCoords() << endl;
    
    //load the texture shader
    shader.load("tex.vert", "tex.frag");
    
    //fft init
    fftSmoothed = new float[8192];
    memset(fftSmoothed, 0x00, sizeof(float) * 8192);
    
    //map the frequencies to bark bands
    float freq_spc = FREQ_MAX / (float)SPECTRAL_BANDS;
    
	for (int i = 0; i < SPECTRAL_BANDS; i++) {
        int bidx = bark(i * freq_spc);
        barkmap[i] = bidx;
    }
    
    //load the position updating frag shader
    pos_shader.load("", "position.frag");
    
    //for the sphere we set this to the resolution which = #of verts along each axis
    fbo_res = res;
    
    //init the fbo's with blank data
    vector<ofVec3f> fbo_init_data;
    fbo_init_data.assign(fbo_res * fbo_res, ofVec3f(0.0, 0.0, 0.0));
    
    posbuf.allocate(fbo_res, fbo_res, GL_RGB32F);
    posbuf.src->getTextureReference().loadData((float *)&fbo_init_data[0], fbo_res, fbo_res, GL_RGB);
    posbuf.dst->getTextureReference().loadData((float *)&fbo_init_data[0], fbo_res, fbo_res, GL_RGB);
    
    //reuse fbo_init_data for no real reason, it just needs to be blank
    eq_tex.allocate(fbo_res, 1, GL_RGB32F_ARB);
    eq_tex.loadData((float *)&fbo_init_data[0], fbo_res, 1, GL_RGB);
    
    axis_loc = fbo_res;
    angincr = 180.0/(float)fbo_res;

    player.loadSound("jhfd.mp3");
    
    player.play(); //go
}