3D Game Programming
After we build a new camera, we need to add it to the scene. Like anything else in 3D programming, the camera is placed at the c ...
In the case of the renderer, we can already see why it’s nice to have this kind of control. In some of our experiments, we rende ...
varshape =newTHREE.CubeGeometry(200, 1000, 10); varcover =newTHREE.MeshBasicMaterial({color:0x990000}); varroad =newTHREE.Mesh(s ...
That is the same road from the previous image. We’ve only replaced the two lines that create the perspective camera with the fol ...
CHAPTER 10 Project: Collisions We have a pretty slick game avatar. It moves, it walks, it even turns. But you may have noticed s ...
10.2 Rays and Intersections The way we prevent our avatar from walking through trees is actually quite simple. Imagine an arrow ...
If, at any time, we find that the next movement would place the avatar’s ray so that it points through the circle, we stop the a ...
Let’s establish the list that will hold all forbidden boundaries. Just below the START CODING ON THE NEXT LINE line, add the fol ...
avatar’s marker.position). We then ask that ray if it goes through (intersects) any of the not_allowed objects. If the ray does ...
Yay! That might seem like some pretty easy code, but you just solved a very hard problem in game programming. 12.6 The Code So F ...
CHAPTER 11 Project: Fruit Hunt We have an avatar. We have trees. Let’s make a game in which our avatar has to get stuff out of t ...
From the menu in the ICE Code Editor, select Make a Copy and enter Fruit Hunt! as the new project name. To keep score in this ga ...
Before making the game behave the way the help text says it should, we need to teach the game what to do when time runs out. To ...
pushing nothing onto our list of trees. Add the following line to the very bottom of the makeTreeAt() function before the last c ...
The last part of shakeTree() sets a timeout for 12 seconds. After 12 seconds have passed, this timeout calls the shakeTree() fun ...
The checkForTreasure() function does three things: If there is no active tree—if it is undefined, as described in Describing a ...
11.5 Making Our Games Even Better We’ve spent a good deal of time in this book adding animations to our avatar. We do this partl ...
fruit =newTHREE.Mesh( newTHREE.CylinderGeometry(25, 25, 5, 25), newTHREE.MeshBasicMaterial({color: 0xFFD700}) ); fruit.rotation. ...
What Else Can We Add? This is it for our avatar that we built from scratch starting all the way back in Chapter 3, Project: Maki ...
CHAPTER 12 Working with Lights and Materials In this chapter we’ll cover how to build interesting shapes and materials that look ...
«
1
2
3
4
5
6
7
8
9
10
»
Free download pdf