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

Function demo1Create

src/examples/physics/physics.cpp:129–176  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

127static int bodyCount = 0;
128
129void demo1Create() {
130 defaultDrawOptions();
131
132 createJointAndBody();
133
134 mWindow->setTitle( "eepp - Physics - Logo Smash" );
135
136 mSpace = Physics::Space::New();
137 mSpace->setIterations( 1 );
138
139 // The space will contain a very large number of similarly sized objects.
140 // This is the perfect candidate for using the spatial hash.
141 // Generally you will never need to do this.
142 mSpace->useSpatialHash( 2.0, 10000 );
143
144 bodyCount = 0;
145
146 Body* body;
147 Shape* shape;
148
149 Float pX = mWindow->getWidth() / 2 - ( image_width * 4 ) / 2;
150 Float pY = mWindow->getHeight() / 2 - ( image_height * 4 ) / 2;
151
152 for ( int y = 0; y < image_height; y++ ) {
153 for ( int x = 0; x < image_width; x++ ) {
154 if ( !get_pixel( x, y ) )
155 continue;
156
157 shape = make_ball( pX + x * 4, pY + y * 4 );
158
159 mSpace->addBody( shape->getBody() );
160 mSpace->addShape( shape );
161
162 bodyCount++;
163 }
164 }
165
166 body = mSpace->addBody( Body::New( INFINITY, INFINITY ) );
167 body->setPos( cVectNew( 0, mWindow->getHeight() / 2 + 16 ) );
168 body->setVel( cVectNew( 400, 0 ) );
169
170 shape = mSpace->addShape( ShapeCircle::New( body, 8.0f, cVectZero ) );
171 shape->setElasticity( 0.0 );
172 shape->setFriction( 0.0 );
173 shape->setLayers( NOT_GRABABLE_MASK );
174
175 bodyCount++;
176}
177
178void demo1Update() {}
179

Callers 1

physicsCreateMethod · 0.85

Calls 15

defaultDrawOptionsFunction · 0.85
createJointAndBodyFunction · 0.85
get_pixelFunction · 0.85
make_ballFunction · 0.85
useSpatialHashMethod · 0.80
addBodyMethod · 0.80
addShapeMethod · 0.80
setPosMethod · 0.80
setVelMethod · 0.80
setLayersMethod · 0.80
NewFunction · 0.50
setTitleMethod · 0.45

Tested by 1

physicsCreateMethod · 0.68