MCPcopy Create free account
hub / github.com/SpartanJ/eepp / demo2Create

Function demo2Create

src/examples/physics/physics.cpp:184–248  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

182}
183
184void demo2Create() {
185 defaultDrawOptions();
186
187 createJointAndBody();
188
189 mWindow->setTitle( "eepp - Physics - Pyramid Stack" );
190
191 Shape::resetShapeIdCounter();
192
193 mSpace = Physics::Space::New();
194 mSpace->setGravity( cVectNew( 0, 100 ) );
195 mSpace->setSleepTimeThreshold( 0.5f );
196
197 Body *body, *staticBody = mSpace->getStaticBody();
198 Shape* shape;
199
200 shape = mSpace->addShape(
201 ShapeSegment::New( staticBody, cVectNew( 0, mWindow->getHeight() ),
202 cVectNew( mWindow->getWidth(), mWindow->getHeight() ), 0.0f ) );
203 shape->setE( 1.0f );
204 shape->setU( 1.0f );
205 shape->setLayers( NOT_GRABABLE_MASK );
206
207 shape = mSpace->addShape(
208 ShapeSegment::New( staticBody, cVectNew( mWindow->getWidth(), 0 ),
209 cVectNew( mWindow->getWidth(), mWindow->getHeight() ), 0.0f ) );
210 shape->setE( 1.0f );
211 shape->setU( 1.0f );
212 shape->setLayers( NOT_GRABABLE_MASK );
213
214 shape = mSpace->addShape( ShapeSegment::New( staticBody, cVectNew( 0, 0 ),
215 cVectNew( 0, mWindow->getHeight() ), 0.0f ) );
216 shape->setE( 1.0f );
217 shape->setU( 1.0f );
218 shape->setLayers( NOT_GRABABLE_MASK );
219
220 shape = mSpace->addShape( ShapeSegment::New( staticBody, cVectNew( 0, 0 ),
221 cVectNew( mWindow->getWidth(), 0 ), 0.0f ) );
222 shape->setE( 1.0f );
223 shape->setU( 1.0f );
224 shape->setLayers( NOT_GRABABLE_MASK );
225
226 Float hw = mWindow->getWidth() / 2;
227
228 for ( int i = 0; i < 14; i++ ) {
229 for ( int j = 0; j <= i; j++ ) {
230 body = mSpace->addBody( Body::New( 1.0f, Moment::forBox( 1.0f, 30.0f, 30.0f ) ) );
231 body->setPos( cVectNew( hw + j * 32 - i * 16, 100 + i * 32 ) );
232
233 shape = mSpace->addShape( ShapePoly::New( body, 30.f, 30.f ) );
234 shape->setE( 0.0f );
235 shape->setU( 0.8f );
236 }
237 }
238
239 cpFloat radius = 15.0f;
240
241 body =

Callers 1

physicsCreateMethod · 0.85

Calls 15

defaultDrawOptionsFunction · 0.85
createJointAndBodyFunction · 0.85
setSleepTimeThresholdMethod · 0.80
getStaticBodyMethod · 0.80
addShapeMethod · 0.80
setEMethod · 0.80
setUMethod · 0.80
setLayersMethod · 0.80
addBodyMethod · 0.80
setPosMethod · 0.80
NewFunction · 0.50
setTitleMethod · 0.45

Tested by 1

physicsCreateMethod · 0.68