Skip to content

Instantly share code, notes, and snippets.

@vanderlin
Last active January 21, 2021 15:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vanderlin/f12e891435f5c43da1d55400330741b7 to your computer and use it in GitHub Desktop.
Save vanderlin/f12e891435f5c43da1d55400330741b7 to your computer and use it in GitHub Desktop.
basic ofxBox2d circle
//--------------------------------------------------------------
void ofApp::setup() {
// first init box2d
box2d.init();
// set the gravity
box2d.setGravity(0, 10);
// create bounds x,y,w,h
box2d.createBounds();
// enable mouse grabbing
box2d.registerGrabbing();
// set the physics of the circle
circle.setPhysics(1, 0.7, 0.7);
// set the position and size of circle then add to the world
circle.setup(box2d.getWorld(), ofGetWidth()/2, ofGetHeight()/2, 150);
}
//--------------------------------------------------------------
void ofApp::update() {
// update every frame
box2d.update();
}
//--------------------------------------------------------------
void ofApp::draw() {
// draw default circle
circle.draw();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment