Before we add an enemy to the scene, let's clean up our code a little bit and create a new function called addRigidBodies in main.cpp so that all the rigid bodies will be created in a single function. To do so, follow these steps:
- In the source of the main.cpp file, create a new function called addRigidBodies above the main() function.
- Add the following code to the addRigidBodies function. This will add the sphere and ground. We are doing this instead of putting all the game code in the main() function:
// Sphere Rigid Body btCollisionShape* sphereShape = new btSphereShape(1); btDefaultMotionState* sphereMotionState = new
btDefaultMotionState(btTransform(btQuaternion(0, 0, 0, 1),
btVector3(0, 0.5, 0))); btScalar mass = 13.0f; btVector3 sphereInertia(0, 0, 0); sphereShape->calculateLocalInertia(mass, sphereInertia...