3D Game Programming

(C. Jardin) #1

❶Remove the purple color and make this box invisible.


❷Create a new kind of material: an image material.


❸Build a simple mesh with this material.


❹Attach the image mesh to the avatar.


Do the same for the launchFruit() function.


functionlaunchFruit() {
varfruit =newPhysijs.ConvexMesh(
newTHREE.CylinderGeometry(20, 20, 1, 24),
❶ newTHREE.MeshBasicMaterial({visible: false})
);
❷ varmaterial =newTHREE.MeshBasicMaterial({
map: THREE.ImageUtils.loadTexture('/images/fruit.png'),
transparent: true
});
❸ varpicture =newTHREE.Mesh(
newTHREE.PlaneGeometry(40, 40), material
);
❹ picture.rotation.x = -Math.PI/2;
❺ fruit.add(picture);

❶Remove the red color and make this cylinder invisible.


❷Create a new kind of material: an image material.


❸Build a simple mesh with this material.


❹Rotate the image mesh to align with the cylinder.


❺Attach the image mesh to the fruit.


With that, we should have a purple fruit monster on the prowl!


Chapter 15. Project: The Purple Fruit Monster Game • 142


Prepared exclusively for Michael Powell report erratum • discuss

Free download pdf