
#pragma once
#include "ofMain.h"
#include "ofxVectorMath.h"
#include "ofxBox2d.h"

/*
 We need to inharet the box2d contact listener 
 We then get two functions for the contacts
 
 void contactAdd(ofPoint p);
 void contactRemove(ofPoint p);
 
 
 */

class Thing {
public:
	Thing(){
		name = "todd";
		bHit = false;
		r = 0;
	}
	string name;
	int id;
	int r;
	bool bHit;
};


class MusicParticle : public ofxBox2dCircle {
	
public:
	
	Thing* thing;
	
	void init() {
		
		thing = new Thing();
		thing->r = getRadius();
		setData(thing);
	}
	
	void draw() {
		float radius = getRadius();
		
		glPushMatrix();
		glTranslatef(getPosition().x, getPosition().y, 0);
		
		ofSetColor(255*(int)thing->bHit, 0, 255);
		ofFill();
		ofCircle(0, 0, radius);	
		glPopMatrix();
	}
};

// ------------------------------------------------- App
class testApp : public ofBaseApp, public ofxBox2dContactListener {
	
public:
	
	void setup();
	void update();
	void draw();
	
	void keyPressed  (int key);
	void mouseMoved(int x, int y );
	void mouseDragged(int x, int y, int button);
	void mousePressed(int x, int y, int button);
	void mouseReleased(int x, int y, int button);
	void windowResized(int w, int h);
	
	void makeSound(float x, float y, float scl);
	
	ofSoundPlayer				sfx;
	ofxBox2d					box2d;
	vector <MusicParticle>		musicParticles;
	
	void Add(const b2ContactPoint * p);
	
};
