MCPcopy Create free account
hub / github.com/cinder/Cinder / setupWalls

Method setupWalls

samples/FallingGears/src/SceneController.cpp:88–134  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

86}
87
88void SceneController::setupWalls()
89{
90 vec2 center = pointsToMeters( vec2( app::getWindowCenter() ) );
91 float inset = pointsToMeters( mParams.mWallInset );
92
93 vec2 size( center.x - inset, center.y - inset );
94
95 b2BodyDef bodyDef;
96 bodyDef.position.Set( inset, center.y );
97 bodyDef.type = b2_staticBody;
98
99
100 b2EdgeShape leftWallShape;
101 leftWallShape.Set( b2Vec2( 0, - size.y ), b2Vec2( 0, size.y ) );
102
103 b2FixtureDef leftWallFixture;
104 leftWallFixture.shape = &leftWallShape;
105
106 mWalls.push_back( make_shared<Wall>( mAudio ) );
107 auto &leftWall = mWalls.back();
108
109 leftWall->mSide = Wall::Side::LEFT;
110 leftWall->mWidth = mParams.mWallWidth;
111 leftWall->mTag = "left wall";
112 leftWall->mBody = box2d::makeBodyShared( mWorld.get(), bodyDef );
113 leftWall->mBody->CreateFixture( &leftWallFixture );
114 leftWall->mBody->SetUserData( leftWall.get() );
115
116
117 bodyDef.position.Set( pointsToMeters( app::getWindowWidth() ) - inset, center.y );
118
119 b2EdgeShape rightWallShape;
120 rightWallShape.Set( b2Vec2( 0, - size.y ), b2Vec2( 0, size.y ) );
121
122 b2FixtureDef rightWallFixture;
123 rightWallFixture.shape = &rightWallShape;
124
125 mWalls.push_back( make_shared<Wall>( mAudio ) );
126 auto &rightWall = mWalls.back();
127
128 rightWall->mSide = Wall::Side::RIGHT;
129 rightWall->mWidth = mParams.mWallWidth;
130 rightWall->mTag = "right wall";
131 rightWall->mBody = box2d::makeBodyShared( mWorld.get(), bodyDef );
132 rightWall->mBody->CreateFixture( &rightWallFixture );
133 rightWall->mBody->SetUserData( rightWall.get() );
134}
135
136void SceneController::setupFallingGears()
137{

Callers

nothing calls this directly

Calls 11

pointsToMetersFunction · 0.85
getWindowCenterFunction · 0.85
makeBodySharedFunction · 0.85
getWindowWidthFunction · 0.85
backMethod · 0.80
CreateFixtureMethod · 0.80
b2Vec2Class · 0.50
SetMethod · 0.45
push_backMethod · 0.45
getMethod · 0.45
SetUserDataMethod · 0.45

Tested by

no test coverage detected