Game Development Reference
In-Depth Information
For the bullet, we initialize a jigLib.JBox( null, 3, 3, 3 ); object. We set its
length, width, and height to 3 and then set its mass to 10 . We do that for all other
bullets we initialized. This is done with the help of the following code snippet:
function addStageObject(stageObject,location,rotationX,rotationY,
rotationZ){
...
if(stageObject.name=="bullet"){
var cube = new jigLib.JBox( null, 3, 3, 3 );
cube.set_mass(10);
stageObject.rigidBody = cube;
stageObject.system=system;
bullets.push(stageObject);
for(var j=0;j<24;++j){
var bullet=stageObject.clone();
bullet.camera=cam;
bullets.push(bullet);
var cube = new jigLib.JBox( null, 3, 3, 3 );
bullet.rigidBody = cube;
cube.set_mass(10);
cube.set_movable(true);
bullet.system=system;
stage.addModel(bullet);
}
}
...
}
Extending our terrain with physics
In our existing code packets, we have a terrain which is a simple plain, with no bumps
or plateaus or dips. Hence, we use an object of the jigLib.Plain class to represent it
in our physics world. This section intends to end what we started with a true physics
terrain. The following screenshot shows you the terrain that we will be targeting to
initialize in the physics world. It has a bump that starts from the center of the terrain:
 
Search WWH ::




Custom Search