diff --git a/site/real_game/class/Ball.js b/site/real_game/class/Ball.js index e85045d..535e030 100644 --- a/site/real_game/class/Ball.js +++ b/site/real_game/class/Ball.js @@ -6,26 +6,31 @@ /* By: edbernar diffTop) + speed *= -1; + if (this.interval) + clearInterval(this.interval); + this.interval = setInterval(() => { + this.object.position.y += speed; + if ((speed > 0 && this.object.position.y >= this.limits.up) + || (speed < 0 && this.object.position.y <= this.limits.down)) + { + clearInterval(this.interval); + this.interval = null; + if (speed > 0) + this.setPosition(this.object.position.x, this.limits.up, this.object.position.z); + else + this.setPosition(this.object.position.x, this.limits.down, this.object.position.z); + } + }, 10); + } + + /*---------------- FUNCTION FOR TEST ----------------*/ + initMoveBallTmp() + { + console.warn("Don't forget to remove function initMoveBallTmp"); + const speedBallTmp = 0.1; + + document.addEventListener('keypress', (e) => { + if (e.key == '4') + this.object.position.x -= speedBallTmp; + if (e.key == '6') + this.object.position.x += speedBallTmp; + if (e.key == '8') + this.object.position.z -= speedBallTmp; + if (e.key == '2') + this.object.position.z += speedBallTmp; + if (e.key == '9') + this.changeGravity(); + }); + } + /*---------------------------------------------------*/ } + export { Ball }; \ No newline at end of file diff --git a/site/real_game/class/Map.js b/site/real_game/class/Map.js index 8421c22..0d4fb3b 100644 --- a/site/real_game/class/Map.js +++ b/site/real_game/class/Map.js @@ -3,29 +3,43 @@ /* ::: :::::::: */ /* Map.js :+: :+: :+: */ /* +:+ +:+ +:+ */ -/* By: hubourge +#+ +:+ +#+ */ +/* By: edbernar 2) + this.arrObject[i].mesh.material.opacity = 0; + else + this.arrObject[i].mesh.material.opacity = 1 - (diff / 2); + } + if (this.arrObject[i].name == "wallRight") + { + let diff = this.arrObject[i].mesh.position.x - ball.position.x - 0.1; + + if (diff > 2) + this.arrObject[i].mesh.material.opacity = 0; + else + this.arrObject[i].mesh.material.opacity = 1 - (diff / 2); + } } } }; diff --git a/site/real_game/class/Player.js b/site/real_game/class/Player.js index 67a5138..77dfba5 100644 --- a/site/real_game/class/Player.js +++ b/site/real_game/class/Player.js @@ -6,7 +6,7 @@ /* By: edbernar { playerExist = false; }) @@ -110,20 +102,20 @@ class Player { this.setCameraPosition( this.object.position.x, - this.object.position.y - (this.object.position.y >= limits.up ? 0.7 : -0.7), - this.object.position.z + 1 + this.object.position.y - (this.object.position.y >= this.limits.up ? 0.7 : -0.7), + this.object.position.z + 2 ); this.camera.rotation.set(0, 0, 0); } else - this.setCameraPosition(0, 1.5, 2.6); + this.setCameraPosition(0, 1.5, 4); } }); } pointAnimation(scene) { - const tmpCamera = new THREE.PerspectiveCamera(80, window.innerWidth / window.innerHeight, 0.1, 10000); + const tmpCamera = new THREE.PerspectiveCamera(70, window.innerWidth / window.innerHeight, 0.1, 10000); const tmp = this.camera; let interval = null; const startColor = this.object.material.color.clone(); @@ -136,7 +128,7 @@ class Player document.getElementsByTagName('canvas')[0].style.filter = 'brightness(1)'; }, 300) setTimeout(() => { - tmpCamera.position.set(-3, 3, -3); + tmpCamera.position.set(-3, this.limits.up / 2 + 0.5, -3); this.isOnPointAnim = true; this.camera = tmpCamera; interval = setInterval(() => { @@ -161,17 +153,13 @@ class Player { this.setCameraPosition( this.object.position.x, - this.object.position.y - (this.object.position.y >= limits.up ? 0.7 : -0.7), - this.object.position.z + 1 + this.object.position.y - (this.object.position.y >= this.limits.up ? 0.7 : -0.7), + this.object.position.z + 2 ); } document.getElementsByTagName('canvas')[0].style.animation = 'fadeOut 0.199s'; document.getElementsByTagName('canvas')[0].style.filter = 'brightness(1)'; }, 200); - // document.getElementsByTagName('canvas')[0].style.filter = 'brightness(0)'; - // setTimeout(() => { - // document.getElementsByTagName('canvas')[0].style.animation = 'fadeOut 0.199s'; - // }, 300) }, 4000); }, 200) } @@ -183,7 +171,7 @@ class Player i = 0; while (i < this.pressedButton.length) { - if (this.pressedButton[i] == 'w' && this.object.position.y < limits.up) + if (this.pressedButton[i] == 'w' && this.object.position.y < this.limits.up) { if (this.interval) clearInterval(this.interval); @@ -191,14 +179,14 @@ class Player this.object.position.y += this.speed; if (!this.cameraFixed && !this.isOnPointAnim) this.camera.position.y += (this.speed / 2); - if (this.object.position.y >= limits.up) + if (this.object.position.y >= this.limits.up) { clearInterval(this.interval); this.interval = null; } }, 5); } - if (this.pressedButton[i] == 's' && this.object.position.y > limits.down) + if (this.pressedButton[i] == 's' && this.object.position.y > this.limits.down) { if (this.interval) clearInterval(this.interval); @@ -206,20 +194,20 @@ class Player this.object.position.y -= this.speed; if (!this.cameraFixed && !this.isOnPointAnim) this.camera.position.y -= (this.speed / 2); - if (this.object.position.y <= limits.down) + if (this.object.position.y <= this.limits.down) { clearInterval(this.interval); this.interval = null; } }, 5); } - if (this.pressedButton[i] == 'd' && this.object.position.x < limits.right) + if (this.pressedButton[i] == 'd' && this.object.position.x < this.limits.right) { this.object.position.x += this.speed; if (!this.cameraFixed && !this.isOnPointAnim) this.camera.position.x += this.speed; } - if (this.pressedButton[i] == 'a' && this.object.position.x > limits.left) + if (this.pressedButton[i] == 'a' && this.object.position.x > this.limits.left) { this.object.position.x -= this.speed; if (!this.cameraFixed && !this.isOnPointAnim) diff --git a/site/real_game/main.js b/site/real_game/main.js index 2bdf64d..7cbd98b 100644 --- a/site/real_game/main.js +++ b/site/real_game/main.js @@ -6,15 +6,14 @@ /* By: edbernar { - if (e.key == '9') - { - ball.position.z += speed; - console.log(e.key); - } -}); -// ===================== scene.add(player.object); scene.add(ambiantLight); @@ -82,6 +54,7 @@ scene.add(spotLight); scene.background = new THREE.Color(0x1a1a1a); renderer.setSize(window.innerWidth, window.innerHeight); document.body.appendChild(renderer.domElement); +ball.initMoveBallTmp(); document.addEventListener('keypress', (e) => { if (e.key == 'g') diff --git a/site/real_game/node_modules/.vite/deps/_metadata.json b/site/real_game/node_modules/.vite/deps/_metadata.json index 136e9ca..788e3b5 100644 --- a/site/real_game/node_modules/.vite/deps/_metadata.json +++ b/site/real_game/node_modules/.vite/deps/_metadata.json @@ -1,25 +1,25 @@ { - "hash": "b5ed7c4e", - "configHash": "4027b9ee", + "hash": "aeb97021", + "configHash": "0b4c6e74", "lockfileHash": "cd36b699", - "browserHash": "c12de373", + "browserHash": "84f752d1", "optimized": { "three": { "src": "../../three/build/three.module.js", "file": "three.js", - "fileHash": "2e49ea84", + "fileHash": "a5c835fb", "needsInterop": false }, "three/examples/jsm/Addons.js": { "src": "../../three/examples/jsm/Addons.js", "file": "three_examples_jsm_Addons__js.js", - "fileHash": "a119f2f8", + "fileHash": "aa17f873", "needsInterop": false }, "three/examples/jsm/libs/tween.module.js": { "src": "../../three/examples/jsm/libs/tween.module.js", "file": "three_examples_jsm_libs_tween__module__js.js", - "fileHash": "4f2aca7a", + "fileHash": "b4479a8c", "needsInterop": false } }, diff --git a/site/real_game/textures/testTmp.jpg b/site/real_game/textures/testTmp.jpg new file mode 100644 index 0000000..2034117 Binary files /dev/null and b/site/real_game/textures/testTmp.jpg differ