To update the enemy's movement, we will add a tick function that will be called by the rigid body world. In this tick function, we will update the position of the enemy so that the enemy cube moves from the right of the screen to the left. We will also check whether the enemy has gone beyond the left-hand side of the screen.
If it has, then we will reset its position to the right of the screen. To do so, follow these steps:
- In this update function, we will also update our gameplay logic and scoring, as well as how we check for contact between the sphere and the enemy and the sphere and the ground. Add the tick function callback prototype to the top of the Main.cpp file, as follows:
void myTickCallback(btDynamicsWorld *dynamicsWorld,
btScalar timeStep);
- In the TickCallback function, update the position of the enemy, as follows:
void myTickCallback...