Created
September 9, 2013 13:49
-
-
Save vanderlin/6495829 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "testApp.h" | |
#include "ofxBox2d.h" | |
ofxBox2d box2d; | |
vector <ofxBox2dPolygon> triangles; | |
//-------------------------------------------------------------- | |
void testApp::setup(){ | |
ofSetFrameRate(30); | |
ofBackground(255, 0, 255); | |
box2d.init(); | |
box2d.setGravity(0, 20); | |
box2d.createBounds(); | |
} | |
//-------------------------------------------------------------- | |
void testApp::update(){ | |
box2d.update(); | |
} | |
//-------------------------------------------------------------- | |
void testApp::draw(){ | |
for (int i=0; i<triangles.size(); i++) { | |
ofPolyline poly(triangles[i].getVertices()); | |
poly.close(); | |
poly.draw(); | |
} | |
} | |
//-------------------------------------------------------------- | |
void testApp::keyPressed(int key){ | |
} | |
//-------------------------------------------------------------- | |
void testApp::keyReleased(int key){ | |
} | |
//-------------------------------------------------------------- | |
void testApp::mouseMoved(int x, int y ){ | |
} | |
//-------------------------------------------------------------- | |
void testApp::mouseDragged(int x, int y, int button){ | |
} | |
//-------------------------------------------------------------- | |
void testApp::mousePressed(int x, int y, int button){ | |
ofxBox2dPolygon tri; | |
tri.addTriangle(ofPoint(x-10, y), ofPoint(x, y-10), ofPoint(x+10, y)); | |
tri.setAsEdge(false); | |
tri.setPhysics(1.0, 0.7, 1.0); | |
tri.create(box2d.getWorld()); | |
triangles.push_back(tri); | |
} | |
//-------------------------------------------------------------- | |
void testApp::mouseReleased(int x, int y, int button){ | |
} | |
//-------------------------------------------------------------- | |
void testApp::windowResized(int w, int h){ | |
} | |
//-------------------------------------------------------------- | |
void testApp::gotMessage(ofMessage msg){ | |
} | |
//-------------------------------------------------------------- | |
void testApp::dragEvent(ofDragInfo dragInfo){ | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment