#ifndef _TEST_APP
#define _TEST_APP

#include "ofMain.h"
#include "ofAddons.h"
#include "ofShader.h"


//stupid ball class - currently draws rectangles
//as we haven't got display lists working and ofCircle uses 
//a display list

class ball{
	
	public:
		ball(){
		
		}
		
		void setup(float x, float y, float r){
			pos.x = x;
			pos.y = y;
			pos.z = r;
			
			vel.x = 2.0;
			vel.y = 1.6;
		}	
		
		void update(int width, int height){
			if( pos.x + pos.z >= width){
				pos.x = width - pos.z;
				vel.x *= -1;
			}else if( pos.x - pos.z <= 0){
				pos.x = pos.z;
				vel.x *= -1;
			}
			
			if( pos.y + pos.z >= height){
				pos.y = height - pos.z;
				vel.y *= -1;
			}else if( pos.y - pos.z <= 0){
				pos.y = pos.z;
				vel.y *= -1;
			}
			
			pos.x += vel.x;
			pos.y += vel.y;
		}
		
		void draw(){	
			ofSetRectMode(OF_RECTMODE_CENTER);
			ofRect(pos.x, pos.y, pos.z*2, pos.z*2);
			ofSetRectMode(OF_RECTMODE_CORNER);			
		}
		
		ofPoint pos;
		ofPoint vel;
	
};

class testApp : public ofSimpleApp{
	
	public:
		
		void setup();
		void update();
		void draw();
		
		void keyPressed(int key);
		void keyReleased(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();
		
		
		ofImage img;
		ofShader temp;
		ball balls[20];
		
		ofPoint corners[4];
		int whichCorner;
};

#endif	

