From 76a746efb143af5436587b917a01de5f0db27bcd Mon Sep 17 00:00:00 2001 From: Kum1ta Date: Tue, 27 Aug 2024 15:26:38 +0200 Subject: [PATCH] Game - Starting class --- site/real_game/class/Ball.js | 19 ++-- site/real_game/class/Map.js | 6 +- site/real_game/class/Opponent.js | 7 +- site/real_game/class/Player.js | 6 +- site/real_game/class/Video.js | 7 +- site/real_game/main.js | 140 +++++++++++++++++++----------- site/real_game/textures/.DS_Store | Bin 0 -> 6148 bytes 7 files changed, 107 insertions(+), 78 deletions(-) create mode 100644 site/real_game/textures/.DS_Store diff --git a/site/real_game/class/Ball.js b/site/real_game/class/Ball.js index f04b955..b5c1222 100644 --- a/site/real_game/class/Ball.js +++ b/site/real_game/class/Ball.js @@ -3,22 +3,14 @@ /* ::: :::::::: */ /* Ball.js :+: :+: :+: */ /* +:+ +:+ +:+ */ -/* By: hubourge +#+ +:+ +#+ */ +/* By: edbernar +#+ +:+ +#+ */ +/* By: edbernar +#+ +:+ +#+ */ +/* By: edbernar +#+ +:+ +#+ */ +/* By: edbernar +#+ +:+ +#+ */ +/* By: edbernar +#+ +:+ +#+ */ +/* By: edbernar { + if (e.key == 'g') + player.pointAnimation(map); + if (e.key == 'h') + player.pointOpponentAnimation(map, opponent.object); + if (e.key == 'c') + debug = !debug; + }) + + renderer.setAnimationLoop(loop) + } + + static dispose() + { + scene = null; + debug = false; + } +} + + function createBarPlayer(color) { const geometry = new THREE.BoxGeometry(1, 0.1, 0.1); @@ -55,15 +129,17 @@ function createBarPlayer(color) return (mesh); } -let previousTime = Date.now(); function loop() { stats.begin(); // ===== FPS locker ===== // - const currentTime = Date.now(); - if (currentTime - previousTime < 1000 / 60) - return ; - previousTime = currentTime; + if (fpsLocker.status) + { + const currentTime = Date.now(); + if (currentTime - previousTime < 1000 / 60) + return ; + previousTime = currentTime; + } // ====================== // player.update(); @@ -79,46 +155,4 @@ function loop() stats.end(); } -const scene = new THREE.Scene(); -const map = new Map(scene, 13, true); -const bar1 = createBarPlayer(0xed56ea); -const renderer = new THREE.WebGLRenderer({antialias: true}); -renderer.shadowMap.enabled = true; -renderer.shadowMap.type = THREE.PCFSoftShadowMap; -const player = new Player(bar1, map); -const spotLight = new THREE.SpotLight(0xffffff, 10000, 0, 0.2); -spotLight.castShadow = true; -const ambiantLight = new THREE.AmbientLight(0xffffff, 0.5); -const ball = new Ball(scene, map); -const bar2 = createBarPlayer(0xf3e11e); -const opponent = new Opponent(bar2, map); - - -scene.add(player.object); -scene.add(opponent.object); -scene.add(ambiantLight); -spotLight.position.set(0, 100, 0); -scene.add(spotLight); -scene.background = new THREE.Color(0x1a1a1a); -renderer.setSize(window.innerWidth, window.innerHeight); -document.body.appendChild(renderer.domElement); -ball.initMoveBallTmp(); -map.ballObject = ball.object; - -/*---------------DEBUG----------------*/ -const cameraTmp = new THREE.PerspectiveCamera(90, window.innerWidth / window.innerHeight); -const controls = new OrbitControls(cameraTmp, renderer.domElement); -cameraTmp.position.set(5, 3, 5); -controls.target = new THREE.Vector3(map.centerPos.x, 0, map.centerPos.z); -/*------------------------------------*/ - -document.addEventListener('keypress', (e) => { - if (e.key == 'g') - player.pointAnimation(map); - if (e.key == 'h') - player.pointOpponentAnimation(map, opponent.object); - if (e.key == 'c') - debug = !debug; -}) - -renderer.setAnimationLoop(loop) +Game.create(); \ No newline at end of file diff --git a/site/real_game/textures/.DS_Store b/site/real_game/textures/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..1255e26f0f07a7dac7e4c85fae7dbf7003d58973 GIT binary patch literal 6148 zcmeHKI|>3Z5S{S@f{mqRuHX%V=n1@l#fk``AZWdn=kjR2`83P2ofgU)n7m{%FCnkk z*%1+4-}>w&gLxhmpaMUyfPEhd+^{CLf&S^h;4J`fg0LIr-b(Cld`t<9%r?-!1r*=dBM#vcM1kC$3QQ~SXen;dQ#*Sn`6Hw Uwt-GZ-0496445u7D)4Ou-bFkV%m4rY literal 0 HcmV?d00001