Carry out the following steps:
1. We are still working only on the logic part. Open our JavaScript logic file in a text editor.
2. Add the following global variable at the top of the document to reference the car body:
var car;
3. Create a function named
createCarAt
which takes the coordinate as arguments. Then, we move the body and the wheel creation code in this function. Afterwards, add the following highlighted Joint creation code. At last, return the car body:function createCarAt(x, y) { // the car box definition var boxSd = new b2BoxDef(); boxSd.density = 1.0; boxSd.friction = 1.5; boxSd.restitution = .4; boxSd.extents.Set(40, 20); // the car body definition var boxBd = new b2BodyDef(); boxBd.AddShape(boxSd); boxBd.position.Set(x,y); var carBody = carGame.world.CreateBody(boxBd); // creating the wheels var wheelBody1 = createWheel(carGame.world, x-25, y+20); var wheelBody2 = createWheel(carGame.world, x+25,...