Let's wrap this up by adding scoring and finishing the game loop:
- Along with the grounded Boolean, add another Boolean and check for gameover. After doing this, add an int called score and initialize it to 0 at the top of the main.cpp file, as follows:
GLuint sphereTexture, groundTexture; bool grounded = false; bool gameover = true; int score = 0;
- Next, in the tick function, the enemy should only move when the game is not over. So we wrap the update for the position of the enemy inside an if statement to check whether or not the game is over. If the game is not over, then we update the position of the enemy, as follows:
void myTickCallback(btDynamicsWorld *dynamicsWorld, btScalar timeStep) { if (!gameover) { // Get enemy transform btTransform t(enemy->rigidBody->getWorldTransform()); // Set...