- Starting solo game
This commit is contained in:
Kum1ta
2024-08-28 17:30:46 +02:00
parent 6aa715978e
commit 2fdba63def
5 changed files with 265 additions and 18 deletions

View File

@ -6,18 +6,23 @@
/* By: edbernar <edbernar@student.42angouleme. +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/08/28 12:07:39 by edbernar #+# #+# */
/* Updated: 2024/08/28 14:07:55 by edbernar ### ########.fr */
/* Updated: 2024/08/28 16:48:12 by edbernar ### ########.fr */
/* */
/* ************************************************************************** */
import * as THREE from 'three';
import { Map } from './soloClass/Map.js'
import { Players } from './soloClass/Players.js'
import { Ball } from './soloClass/Ball.js'
import { stats } from './MultiGame.js';
import { OrbitControls } from 'three/examples/jsm/controls/OrbitControls.js';
let scene = null;
let renderer = null;
let camera = null;
let map = null;
let controls = null;
class SoloGame
{
@ -25,21 +30,25 @@ class SoloGame
{
scene = new THREE.Scene();
renderer = new THREE.WebGLRenderer({antialias: true});
map = new Map(scene);
camera = new THREE.PerspectiveCamera(70, window.innerWidth / window.innerWidth);
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
Map.create(scene);
camera = new THREE.PerspectiveCamera(70, window.innerWidth / window.innerHeight);
camera.rotation.x = -Math.PI / 2;
renderer.setSize(window.innerWidth, window.innerWidth);
scene.background = new THREE.Color(0xaaaaaa);
renderer.setSize(window.innerWidth, window.innerHeight);
scene.background = new THREE.Color(0x252525);
document.body.appendChild(renderer.domElement);
scene.add(new THREE.AmbientLight(0xffffff, 1));
Players.create(scene);
Ball.create(scene);
controls = new OrbitControls(camera, renderer.domElement);
camera.position.set(0, 11, 0);
renderer.setAnimationLoop(loop)
}
static dispose()
{
if (map)
map.dispose();
map = null;
Map.dispose();
if (renderer)
renderer.dispose();
renderer = null;
@ -60,9 +69,13 @@ class SoloGame
}
};
function loop()
{
stats.begin();
controls.update();
Players.update();
Ball.update();
renderer.render(scene, camera);
stats.end();
}