Files
METH_Transcendence/site/real_game/class/soloClass/Ball.js
hubourge f016e411dc Game
- Add ball border transparence
    - Add others collision player on bottom and top
    - Fix ball velocity
2024-09-04 17:50:41 +02:00

57 lines
1.6 KiB
JavaScript

/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* Ball.js :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: hubourge <hubourge@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/08/28 15:58:03 by edbernar #+# #+# */
/* Updated: 2024/09/04 15:07:07 by hubourge ### ########.fr */
/* */
/* ************************************************************************** */
import * as THREE from 'three';
import { wallTop, wallBottom } from './Map.js';
let ball = null;
let speed = 0.15;
let dir = -1;
let interval = null;
class Ball
{
static create(scene)
{
ball = createBall();
scene.add(ball);
ball.rotateY(2.39);
}
static dispose()
{
ball = null;
}
static update()
{
}
}
function createBall()
{
const geometry = new THREE.SphereGeometry(0.3);
const material = new THREE.MeshPhysicalMaterial({color: 0xffffff});
const mesh = new THREE.Mesh(geometry, material);
mesh.position.y += 0.3;
mesh.castShadow = true;
mesh.receiveShadow = true;
mesh.material.transparent = true;
mesh.position.set (0, mesh.position.y, 0);
return (mesh);
}
export { Ball, ball };