console.log(this.title +', starring: ' + this.stars);
};
kung_fu_movie.aboutMe();
// => Kung Fu Panda, starring: Jack Black,Angelina Jolie
vardonut = {
mesh:newTHREE.Mesh(
newTHREE.TorusGeometry(100, 50, 8, 20),
newTHREE.MeshBasicMaterial({color: 0x33cc33})
),
speed: 1,
spin:function() {
varmesh = this.mesh;
scene.add(mesh);
}
};
// Now, show what the camera sees on the screen:
renderer.render(scene, camera);
</script>
A1.18Code: Cave Puzzle
This is the final version of the game code from Chapter 18, Project: Cave
Puzzle, on page 165.
<body></body>
<script src="http://gamingJS.com/Three.js"></script>
<script src="http://gamingJS.com/physi.js"></script>
<script src="http://gamingJS.com/ChromeFixes.js"></script>
<script src="http://gamingJS.com/Scoreboard.js"></script>
<script src="http://gamingJS.com/Mouse.js"></script>
<script>
// Physics settings
Physijs.scripts.ammo ='http://gamingJS.com/ammo.js';
Physijs.scripts.worker ='http://gamingJS.com/physijs_worker.js';
// This is where stuff in our game will happen:
varscene =newPhysijs.Scene({ fixedTimeStep: 2 / 60 });
scene.setGravity(newTHREE.Vector3( 0, -100, 0 ));
// This is what sees the stuff:
varwidth = window.innerWidth,
height = window.innerHeight,
aspect_ratio = width / height;
//var camera = new THREE.PerspectiveCamera(75, aspect_ratio, 1, 10000);
varcamera =newTHREE.OrthographicCamera(
report erratum • discuss
Code: Cave Puzzle • 255
Prepared exclusively for Michael Powell