Last active
January 21, 2021 15:51
-
-
Save vanderlin/f12e891435f5c43da1d55400330741b7 to your computer and use it in GitHub Desktop.
basic ofxBox2d circle
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
//-------------------------------------------------------------- | |
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