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

Function demo4Create

src/examples/physics/physics.cpp:472–547  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

470}
471
472void demo4Create() {
473 PhysicsManager::DrawSpaceOptions* DSO = PhysicsManager::instance()->getDrawOptions();
474 DSO->DrawBBs = false;
475 DSO->DrawShapes = true;
476 DSO->DrawShapesBorders = false;
477 DSO->CollisionPointSize = 0;
478 DSO->BodyPointSize = 0;
479 DSO->LineThickness = 0;
480
481 createJointAndBody();
482
483 mWindow->setTitle( "eepp - Physics - Sticky collisions using the Arbiter data pointer." );
484
485 mSpace = Space::New();
486 mSpace->setIterations( 10 );
487 mSpace->setGravity( cVectNew( 0, 1000 ) );
488 mSpace->setCollisionSlop( 2.0 );
489
490 Body* staticBody = mSpace->getStaticBody();
491 Shape* shape;
492
493 cpFloat x = 500;
494 cpFloat y = 400;
495
496 shape = mSpace->addShape( ShapeSegment::New( staticBody, cVectNew( x + -340, y - 260 ),
497 cVectNew( x - 340, y + 260 ), 20.0f ) );
498 shape->setElasticity( 1.0f );
499 shape->setFriction( 1.0f );
500 shape->setCollisionType( COLLIDE_STICK_SENSOR );
501 shape->setLayers( NOT_GRABABLE_MASK );
502
503 shape = mSpace->addShape( ShapeSegment::New( staticBody, cVectNew( x + 340, y - 260 ),
504 cVectNew( x + 340, y + 260 ), 20.0f ) );
505 shape->setElasticity( 1.0f );
506 shape->setFriction( 1.0f );
507 shape->setCollisionType( COLLIDE_STICK_SENSOR );
508 shape->setLayers( NOT_GRABABLE_MASK );
509
510 shape = mSpace->addShape( ShapeSegment::New( staticBody, cVectNew( x - 340, y - 260 ),
511 cVectNew( x + 340, y - 260 ), 20.0f ) );
512 shape->setElasticity( 1.0f );
513 shape->setFriction( 1.0f );
514 shape->setCollisionType( COLLIDE_STICK_SENSOR );
515 shape->setLayers( NOT_GRABABLE_MASK );
516
517 shape = mSpace->addShape( ShapeSegment::New( staticBody, cVectNew( x - 340, y + 260 ),
518 cVectNew( x + 340, y + 260 ), 20.0f ) );
519 shape->setElasticity( 1.0f );
520 shape->setFriction( 1.0f );
521 shape->setCollisionType( COLLIDE_STICK_SENSOR );
522 shape->setLayers( NOT_GRABABLE_MASK );
523
524 for ( int i = 0; i < 200; i++ ) {
525 cpFloat mass = 0.15f;
526 cpFloat radius = 10.0f;
527
528 Body* body = mSpace->addBody(
529 Body::New( mass, Moment::forCircle( mass, 0.0f, radius, cVectZero ) ) );

Callers

nothing calls this directly

Calls 15

createJointAndBodyFunction · 0.85
linearInterpolationFunction · 0.85
randfFunction · 0.85
getDrawOptionsMethod · 0.80
setCollisionSlopMethod · 0.80
getStaticBodyMethod · 0.80
addShapeMethod · 0.80
setCollisionTypeMethod · 0.80
setLayersMethod · 0.80
addBodyMethod · 0.80
setPosMethod · 0.80
addCollisionHandlerMethod · 0.80

Tested by

no test coverage detected