3D Game Programming
} shape.computeFaceNormals(); shape.computeVertexNormals(); returncenter_points; } The main purpose of this function is to find ...
Figure 9—The River Trench one for the lid, which will be invisible. We already have empty addWater() and addLid() functions that ...
With that, we have a cool-looking river winding its way through the land: Finally, we define the lid function as the following: ...
}), 0.1, 0.01 ) ); mesh.rotation.x = -Math.PI/2; mesh.castShadow = true; scene.add(mesh); mesh.setAngularFactor(newTHREE.Vector3 ...
raft.position.set(start.y, start.z + 100, 0); raft.setLinearVelocity(newTHREE.Vector3()); scoreboard.resetTimer(); scoreboard.sc ...
document.addEventListener("keydown",function(event) { varcode = event.keyCode; if(code == 32) pushRaft(); // space if(code == 37 ...
varpaused; startGame(raft, river, scoreboard); Other functions will use that variable to decide if they need to animate or updat ...
functiongameStep() { // Update physics 60 times a second so that motion is smooth setTimeout(gameStep, 1000/60); if(paused)retur ...
If you want to increase the score as the raft makes its way along the river, we can add a call to the updateScore() function in ...
points and 200 more are awarded. If the player finishes in less than 20 sec- onds, then the 100 and the 200 points are awarded, ...
functionremoveItems() { game_items.forEach(function(item) { scene.remove(item); }); game_items = []; } Adding items to the river ...
If Math.random() is 1 , then 10Math.random() is 10 , making 20 + 10Math.random() end up as 30. In other words, since Math.rand ...
Also new to us is converting from local coordinates to world coordinates with the localToWorld() method. For most of this book w ...
CHAPTER 21 Getting Code on the Web Since we’re programming a web language, it’s worth a quick look at how the Web works. We’re n ...
21.1 The Mighty, Mighty Browser Behold the mighty browser: A web browser is an extraordinarily complex piece of technology that ...
Web Servers Must Be Publicly Available on the Internet Remember that the machine holding a website must be publicly available on ...
This is the kind of dumb part. The web page is usually pretty small and uninteresting. Web pages often look pretty and do lots o ...
Some markup has things like JavaScript files or images or styles that make cool stuff happen. And so, as soon as the browser get ...
the DOM to make changes to web pages (change colors, show pop-up boxes). When the browser has read a web page and converted it i ...
Most free websites have their own way to create web pages, script files and images. To get an idea of how to copy some of our pr ...
«
6
7
8
9
10
11
12
13
14
15
»
Free download pdf