2323 lightBlue : 0x9CBFE3
2424} ;
2525var camera_x ;
26+ var camera_y ;
27+ var camera_z_position ;
28+ var camera_z_look ;
2629var deg2Rad = Math . PI / 180 ;
2730var score ;
2831
@@ -55,8 +58,7 @@ function World() {
5558 objectsCoins ,
5659 paused ,
5760 keysAllowed ,
58- // score,
59- level ,
61+ score ,
6062 difficulty ,
6163 spikePresenceProb ,
6264 maxSpikeSize ,
@@ -75,6 +77,9 @@ function World() {
7577 function init ( ) {
7678 // Locate where the world is to be located on the screen.
7779 camera_x = 0 ;
80+ camera_y = 700 ;
81+ camera_z_position = - 1600 ;
82+ camera_z_look = - 100000 ;
7883 element = document . getElementById ( "world" ) ;
7984
8085 // Initialize the renderer.
@@ -99,11 +104,10 @@ function World() {
99104 1 ,
100105 120000
101106 ) ;
102- // camera.position.set(0, 1500, -2000);
103- // camera.lookAt(new THREE.Vector3(0, 600, -5000));
104107
105- camera . position . set ( 0 , 700 , - 1600 ) ;
106- camera . lookAt ( new THREE . Vector3 ( 0 , 650 , - 10000 ) ) ;
108+ //init camera for first time
109+ camera . position . set ( 0 , camera_y , camera_z_position ) ;
110+ camera . lookAt ( new THREE . Vector3 ( 0 , 650 , camera_z_look ) ) ;
107111 window . camera = camera ;
108112
109113 // Set up resizing capabilities.
@@ -129,17 +133,6 @@ function World() {
129133 scene . add ( cube ) ;
130134 } ) ;
131135
132- // var geometryLeft = new THREE.BoxGeometry(3000, 1000, 120000);
133- // const loaderLeft = new THREE.TextureLoader();
134- // loaderLeft.load("js/lava_text.jpg", (texture) => {
135- // const materialLeft = new THREE.MeshBasicMaterial({ map: texture });
136- // const cubeLeft = new THREE.Mesh(geometryLeft, materialLeft);
137- // cubeLeft.position.set(-1800, -400, -60000);
138- // scene.add(cubeLeft);
139-
140- // cubeLeft.rotation.z =-1.5;
141- // });
142-
143136 var geometryLeft = new THREE . BoxGeometry ( 3000 , 1000 , 120000 ) ;
144137 const loaderLeft = new THREE . TextureLoader ( ) . load ( "images/images (1).jpg" , ( texture ) => {
145138 const materialLeft = new THREE . MeshBasicMaterial ( { map : texture } ) ;
@@ -164,18 +157,6 @@ function World() {
164157 cubeRight . rotation . z = 1.5 ;
165158 } ) ;
166159
167- // var geometryRight = new THREE.BoxGeometry(3000, 1000, 120000);
168- // // const cubes = []; // just an array we can use to rotate the cubes
169- // const loaderRight = new THREE.TextureLoader();
170- // loaderRight.load("js/lava_text.jpg", (texture) => {
171- // const materialRight = new THREE.MeshBasicMaterial({ map: texture });
172- // const cubeRight = new THREE.Mesh(geometryRight, materialRight);
173- // cubeRight.position.set(1800, -400, -60000);
174- // scene.add(cubeRight);
175-
176- // cubeRight.rotation.z =1.5;
177- // });
178-
179160 objects = [ ] ;
180161 objectsCoins = [ ] ;
181162 spikePresenceProb = 0.2 ;
@@ -238,12 +219,10 @@ function World() {
238219 keysAllowed = { } ;
239220 } ) ;
240221
241- // Initialize the scores, level and difficulty.
222+ // Initialize the scores and difficulty.
242223 score = 0 ;
243224 difficulty = 0 ;
244- level = 1 ;
245225 document . getElementById ( "score" ) . innerHTML = score ;
246- document . getElementById ( "level" ) . innerHTML = level ;
247226 document . getElementById ( "coins" ) . innerHTML = coinsCollected ;
248227
249228 // Begin the rendering loop.
@@ -413,14 +392,6 @@ function World() {
413392
414393 // Update the coins collected.
415394 document . getElementById ( "coins" ) . innerHTML = coinsCollected ;
416-
417- //update level based on score
418- if ( score > 1000 ) {
419- document . getElementById ( "level" ) . innerHTML = 2 ;
420- }
421- if ( score > 2000 ) {
422- document . getElementById ( "level" ) . innerHTML = 3 ;
423- }
424395 }
425396
426397 // Render the page and repeat.
@@ -667,8 +638,20 @@ function Character() {
667638 break ;
668639 }
669640 }
670- camera . position . set ( camera_x , 700 , - 1600 ) ;
671- camera . lookAt ( new THREE . Vector3 ( camera_x , 650 , - 10000 ) ) ;
641+ // camera.position.set(camera_x, 700, -1600);
642+ // camera.lookAt(new THREE.Vector3(camera_x, 650, -10000));
643+
644+ // if(camera_y >= 650){
645+ // camera_y -=1;
646+ // }
647+
648+ //follow character
649+ camera_z_position -= 100 ;
650+ camera_z_look -= 100 ;
651+
652+ camera . position . set ( camera_x , camera_y , camera_z_position ) ;
653+ camera . lookAt ( new THREE . Vector3 ( camera_x , 650 , camera_z_look ) ) ;
654+
672655 window . camera = camera ;
673656
674657 // If the character is jumping, update the height of the character.
@@ -739,6 +722,8 @@ function Character() {
739722 }
740723 }
741724 }
725+ //move person forward
726+ self . element . position . z -= 100 ;
742727 } ;
743728
744729 /**
@@ -836,7 +821,7 @@ function Spike(x, y, z, s) {
836821 else {
837822 var geometry = new THREE . BoxGeometry ( 1000 , 500 , 500 ) ;
838823 const loader = new THREE . TextureLoader ( ) ;
839- loader . load ( "js/metal_text .jpg" , ( texture ) => {
824+ loader . load ( "js/future_text .jpg" , ( texture ) => {
840825 const material = new THREE . MeshBasicMaterial ( { map : texture } ) ;
841826 const cube = new THREE . Mesh ( geometry , material ) ;
842827 this . mesh . add ( cube ) ;
@@ -1021,7 +1006,7 @@ function createBox(dx, dy, dz, color, x, y, z, notFlatShading) {
10211006function createCylinder ( radiusTop , radiusBottom , height , radialSegments , color , x , y , z ) {
10221007
10231008 var geom = new THREE . CylinderGeometry ( radiusTop , radiusBottom , height , radialSegments ) ;
1024- const texture = new THREE . TextureLoader ( ) . load ( "js/metal_text .jpg" ) ;
1009+ const texture = new THREE . TextureLoader ( ) . load ( "js/future_text .jpg" ) ;
10251010 const mat = new THREE . MeshStandardMaterial ( { map : texture } )
10261011 var cylinder = new THREE . Mesh ( geom , mat ) ;
10271012 cylinder . castShadow = true ;
0 commit comments