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

Function demo3Create

src/examples/physics/physics.cpp:313–358  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

311}
312
313void demo3Create() {
314 defaultDrawOptions();
315
316 createJointAndBody();
317
318 mWindow->setTitle( "eepp - Physics - Sensor" );
319
320 Shape::resetShapeIdCounter();
321
322 mSpace = Physics::Space::New();
323 mSpace->setIterations( 10 );
324 mSpace->setGravity( cVectNew( 0, 100 ) );
325
326 Body* staticBody = mSpace->getStaticBody();
327 Shape* shape;
328
329 emitterInstance.queue = 5;
330 emitterInstance.blocked = 0;
331 emitterInstance.position = cVectNew( mWindow->getWidth() / 2, 150 );
332
333 shape = mSpace->addShape( ShapeCircle::New( staticBody, 15.0f, emitterInstance.position ) );
334 shape->setSensor( 1 );
335 shape->setCollisionType( BLOCKING_SENSOR_TYPE );
336 shape->setData( &emitterInstance );
337
338 // Create our catch sensor to requeue the balls when they reach the bottom of the screen
339 shape = mSpace->addShape(
340 ShapeSegment::New( staticBody, cVectNew( -4000, 600 ), cVectNew( 4000, 600 ), 15.0f ) );
341 shape->setSensor( 1 );
342 shape->setCollisionType( CATCH_SENSOR_TYPE );
343 shape->setData( &emitterInstance );
344
345 Space::CollisionHandler handler;
346 handler.a = BLOCKING_SENSOR_TYPE;
347 handler.b = BALL_TYPE;
348 handler.begin = &blockerBegin;
349 handler.separate = &blockerSeparate;
350 mSpace->addCollisionHandler( handler );
351
352 handler.reset(); // Reset all the values and the callbacks ( set the callbacks as !IsSet()
353
354 handler.a = CATCH_SENSOR_TYPE;
355 handler.b = BALL_TYPE;
356 handler.begin = &catcherBarBegin;
357 mSpace->addCollisionHandler( handler );
358}
359
360void demo3Update() {
361 if ( !emitterInstance.blocked && emitterInstance.queue ) {

Callers

nothing calls this directly

Calls 14

defaultDrawOptionsFunction · 0.85
createJointAndBodyFunction · 0.85
getStaticBodyMethod · 0.80
addShapeMethod · 0.80
setSensorMethod · 0.80
setCollisionTypeMethod · 0.80
addCollisionHandlerMethod · 0.80
NewFunction · 0.50
setTitleMethod · 0.45
setIterationsMethod · 0.45
setGravityMethod · 0.45
getWidthMethod · 0.45

Tested by

no test coverage detected