Game solo :
- Rebuild collide system Game multi : - Randomize robot profile pictures
This commit is contained in:
@ -3,20 +3,23 @@
|
|||||||
# ::: :::::::: #
|
# ::: :::::::: #
|
||||||
# DummySocket.py :+: :+: :+: #
|
# DummySocket.py :+: :+: :+: #
|
||||||
# +:+ +:+ +:+ #
|
# +:+ +:+ +:+ #
|
||||||
# By: edbernar <edbernar@student.42angouleme. +#+ +:+ +#+ #
|
# By: hubourge <hubourge@student.42.fr> +#+ +:+ +#+ #
|
||||||
# +#+#+#+#+#+ +#+ #
|
# +#+#+#+#+#+ +#+ #
|
||||||
# Created: 2024/10/08 07:33:29 by tomoron #+# #+# #
|
# Created: 2024/10/08 07:33:29 by tomoron #+# #+# #
|
||||||
# Updated: 2024/10/22 17:08:58 by tomoron ### ########.fr #
|
# Updated: 2024/11/18 19:07:29 by hubourge ### ########.fr #
|
||||||
# #
|
# #
|
||||||
# **************************************************************************** #
|
# **************************************************************************** #
|
||||||
|
|
||||||
|
from random import randint
|
||||||
|
|
||||||
class DummySocket:
|
class DummySocket:
|
||||||
def __init__(self, game):
|
def __init__(self, game):
|
||||||
self.id = 0
|
self.id = 0
|
||||||
self.online = True
|
self.online = True
|
||||||
self.username = "bot"
|
self.username = "bot"
|
||||||
self.game = game
|
self.game = game
|
||||||
self.pfp = "/static/img/robot_pfp.jpg"
|
pfpList = ["/static/img/robot_pfp1.jpg", "/static/img/robot_pfp2.jpg", "/static/img/robot_pfp3.jpg", "/static/img/robot_pfp4.jpg"]
|
||||||
|
self.pfp = pfpList[randint(0, 3)]
|
||||||
|
|
||||||
def sync_send(*args):
|
def sync_send(*args):
|
||||||
pass
|
pass
|
||||||
|
@ -3,10 +3,10 @@
|
|||||||
# ::: :::::::: #
|
# ::: :::::::: #
|
||||||
# GameSettings.py :+: :+: :+: #
|
# GameSettings.py :+: :+: :+: #
|
||||||
# +:+ +:+ +:+ #
|
# +:+ +:+ +:+ #
|
||||||
# By: edbernar <edbernar@student.42angouleme. +#+ +:+ +#+ #
|
# By: hubourge <hubourge@student.42.fr> +#+ +:+ +#+ #
|
||||||
# +#+#+#+#+#+ +#+ #
|
# +#+#+#+#+#+ +#+ #
|
||||||
# Created: 2024/10/06 16:33:56 by tomoron #+# #+# #
|
# Created: 2024/10/06 16:33:56 by tomoron #+# #+# #
|
||||||
# Updated: 2024/11/13 13:15:51 by tomoron ### ########.fr #
|
# Updated: 2024/11/18 19:14:37 by hubourge ### ########.fr #
|
||||||
# #
|
# #
|
||||||
# **************************************************************************** #
|
# **************************************************************************** #
|
||||||
|
|
||||||
@ -39,12 +39,13 @@ class GameSettings:
|
|||||||
{ "type":1, "name":"J6", "pos":{"x": 1.5, "y": 0.2, "z": -mapLength / 4}, "isUp": False },
|
{ "type":1, "name":"J6", "pos":{"x": 1.5, "y": 0.2, "z": -mapLength / 4}, "isUp": False },
|
||||||
{ "type":1, "name":"J7", "pos":{"x": 1.5, "y": 3.2, "z": -mapLength / 4}, "isUp": True }
|
{ "type":1, "name":"J7", "pos":{"x": 1.5, "y": 3.2, "z": -mapLength / 4}, "isUp": True }
|
||||||
]
|
]
|
||||||
|
# jumpersPos = [{"type":1, "name":"J"+str(i), "pos":{"x": 1.5 if i & 2 else -1.5, "y": 3.2 if i & 1 else 0.2, "z": -mapLength/4 if i & 4 else mapLength/4}, "isUp": True if i & 1 else False} for i in range(8)]
|
||||||
nbSkins = 8
|
nbSkins = 8
|
||||||
nbGoals = 4
|
nbGoals = 4
|
||||||
wallLength = 1
|
wallLength = 1
|
||||||
wallWidth = 0.05
|
wallWidth = 0.05
|
||||||
bounceSpeedIncrease = 0.2
|
bounceSpeedIncrease = 0.2
|
||||||
maxScore = 2
|
maxScore = 3
|
||||||
|
|
||||||
maxPlayerSpeed = 4
|
maxPlayerSpeed = 4
|
||||||
playerSpeedTolerance = 0.5
|
playerSpeedTolerance = 0.5
|
||||||
|
BIN
docker-compose/requirements/nginx/static/img/robot_pfp2.jpg
Normal file
BIN
docker-compose/requirements/nginx/static/img/robot_pfp2.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 461 KiB |
Before Width: | Height: | Size: 19 KiB After Width: | Height: | Size: 19 KiB |
Before Width: | Height: | Size: 66 KiB After Width: | Height: | Size: 66 KiB |
@ -3,10 +3,10 @@
|
|||||||
/* ::: :::::::: */
|
/* ::: :::::::: */
|
||||||
/* Map.js :+: :+: :+: */
|
/* Map.js :+: :+: :+: */
|
||||||
/* +:+ +:+ +:+ */
|
/* +:+ +:+ +:+ */
|
||||||
/* By: edbernar <edbernar@student.42angouleme. +#+ +:+ +#+ */
|
/* By: hubourge <hubourge@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2024/08/28 12:23:48 by edbernar #+# #+# */
|
/* Created: 2024/08/28 12:23:48 by edbernar #+# #+# */
|
||||||
/* Updated: 2024/11/18 17:02:43 by edbernar ### ########.fr */
|
/* Updated: 2024/11/18 19:24:56 by hubourge ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@ -29,7 +29,8 @@ let initialSpeed = 0;
|
|||||||
let speed = 0;
|
let speed = 0;
|
||||||
let gameEndStatus = false;
|
let gameEndStatus = false;
|
||||||
const scoreToWin = 3;
|
const scoreToWin = 3;
|
||||||
let collided = false;
|
let collidedSide = false;
|
||||||
|
let collidedBlock = false;
|
||||||
let deltaTime = 1;
|
let deltaTime = 1;
|
||||||
let previousTime = Date.now();
|
let previousTime = Date.now();
|
||||||
|
|
||||||
@ -56,19 +57,19 @@ class Map
|
|||||||
wallTop = createWall(true);
|
wallTop = createWall(true);
|
||||||
scene.add(wallTop);
|
scene.add(wallTop);
|
||||||
|
|
||||||
initialSpeed = 0.15;
|
initialSpeed = 0.1;
|
||||||
speed = 1;
|
speed = 0.4;
|
||||||
vec2.z = 0 * initialSpeed;
|
// vec2.z = 0 * initialSpeed;
|
||||||
// if (Math.random() > 0.5)
|
if (Math.random() > 0.5)
|
||||||
// {
|
{
|
||||||
// vec2.z = (Math.random() * 0.8 - 0.4) * initialSpeed;
|
vec2.z = (Math.random() * 0.8 - 0.4) * initialSpeed;
|
||||||
vec2.x = Math.sqrt(initialSpeed * initialSpeed - vec2.z * vec2.z);
|
vec2.x = (speed - Math.abs(vec2.z));
|
||||||
// }
|
}
|
||||||
// else
|
else
|
||||||
// {
|
{
|
||||||
// vec2.z = (Math.random() * 0.8 - 0.4) * initialSpeed;
|
vec2.z = (Math.random() * 0.8 - 0.4) * initialSpeed;
|
||||||
// vec2.x = Math.sqrt(initialSpeed * initialSpeed - vec2.z * vec2.z);
|
vec2.x = -(speed - Math.abs(vec2.z));
|
||||||
// }
|
}
|
||||||
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
scoreElement.innerHTML = '3';
|
scoreElement.innerHTML = '3';
|
||||||
@ -103,62 +104,49 @@ class Map
|
|||||||
return ;
|
return ;
|
||||||
|
|
||||||
// collision wall top and bottom
|
// collision wall top and bottom
|
||||||
if (ball.position.z > 5.7 || ball.position.z < -5.7)
|
if ((ball.position.z > 5.7 || ball.position.z < -5.7) && !collidedBlock)
|
||||||
|
{
|
||||||
|
collidedBlock = true;
|
||||||
vec2.z *= -1;
|
vec2.z *= -1;
|
||||||
|
}
|
||||||
|
|
||||||
// collision player2 left
|
// collision player2 left
|
||||||
if (ball.position.x > 11.45 && ball.position.x < 12.2 && !collided)
|
if (ball.position.x > 11.45 && ball.position.x < 12.2 && !collidedSide)
|
||||||
{
|
{
|
||||||
if (ball.position.z < player2.position.z + 1.25 && ball.position.z > player2.position.z - 1.25)
|
if (ball.position.z < player2.position.z + 1.25 && ball.position.z > player2.position.z - 1.25)
|
||||||
{
|
{
|
||||||
Map.scalePlayer(player2);
|
Map.scalePlayer(player2);
|
||||||
collided = true;
|
collidedSide = true;
|
||||||
vec2.x *= -1;
|
collidedBlock = false;
|
||||||
// Ca bug donc je le laisse en commentaire
|
vec2.z = -((speed * 0.80) * ((player2.position.z - ball.position.z) / 1.25));
|
||||||
// if (ball.position.z < player2.position.z + 0.5)
|
vec2.x = -(speed - Math.abs( vec2.z));
|
||||||
// {
|
|
||||||
// vec2.z -= 0.05;
|
|
||||||
// vec2.x += 0.05;
|
|
||||||
// }
|
|
||||||
// else if (ball.position.z > player2.position.z + 0.5)
|
|
||||||
// {
|
|
||||||
// vec2.z += 0.05;
|
|
||||||
// vec2.x -= 0.05;
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
} // collision player1 right
|
} // collision player1 right
|
||||||
else if (ball.position.x < -11.45 && ball.position.x > -12.2 && !collided)
|
else if (ball.position.x < -11.45 && ball.position.x > -12.2 && !collidedSide)
|
||||||
{
|
{
|
||||||
if (ball.position.z < player1.position.z + 1.25 && ball.position.z > player1.position.z - 1.25)
|
if (ball.position.z < player1.position.z + 1.25 && ball.position.z > player1.position.z - 1.25)
|
||||||
{
|
{
|
||||||
Map.scalePlayer(player1);
|
Map.scalePlayer(player1);
|
||||||
collided = true;
|
collidedSide = true;
|
||||||
vec2.x *= -1;
|
collidedBlock = false;
|
||||||
// Ca bug donc je le laisse en commentaire
|
vec2.z = -((speed * 0.80) * ((player1.position.z - ball.position.z) / 1.25));
|
||||||
// if (ball.position.z < player1.position.z + 0.5)
|
vec2.x = (speed - Math.abs( vec2.z));
|
||||||
// {
|
|
||||||
// vec2.z -= 0.05;
|
|
||||||
// vec2.x += 0.05;
|
|
||||||
// }
|
|
||||||
// else if (ball.position.z > player1.position.z + 0.5)
|
|
||||||
// {
|
|
||||||
// vec2.z += 0.05;
|
|
||||||
// vec2.x -= 0.05;
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// accept new players collision if ball cross the middle map
|
// accept new balls collision if ball cross the middle map
|
||||||
if (collided && ball.position.x < 3 && ball.position.x > -3)
|
if (collidedSide && ball.position.x < 3 && ball.position.x > -3)
|
||||||
collided = false;
|
collidedSide = false;
|
||||||
|
if (collidedBlock && (ball.position.z < 3 && ball.position.z > -3))
|
||||||
|
collidedBlock = false;
|
||||||
|
|
||||||
// velocity
|
// velocity
|
||||||
ball.position.x += vec2.x * speed * deltaTime;
|
ball.position.x += vec2.x * speed * deltaTime;
|
||||||
ball.position.z += vec2.z * speed * deltaTime;
|
ball.position.z += vec2.z * speed * deltaTime;
|
||||||
if (speed < 3)
|
if (speed < 3)
|
||||||
speed += 0.0025;
|
speed += 0.00025;
|
||||||
|
|
||||||
// ball opacity
|
// ball opacitys
|
||||||
if (ball.position.x > 12.3)
|
if (ball.position.x > 12.3)
|
||||||
{
|
{
|
||||||
ball.material.opacity -= 0.1;
|
ball.material.opacity -= 0.1;
|
||||||
@ -220,16 +208,16 @@ class Map
|
|||||||
|
|
||||||
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
initialSpeed = 0.15;
|
initialSpeed = 0.1;
|
||||||
if (player1Lose)
|
if (player1Lose)
|
||||||
{
|
{
|
||||||
vec2.z = (Math.random() * 0.8 - 0.4) * initialSpeed;
|
vec2.z = (Math.random() * 0.8 - 0.4) * initialSpeed;
|
||||||
vec2.x = -Math.sqrt(initialSpeed * initialSpeed - vec2.z * vec2.z);
|
vec2.x = (speed - Math.abs(vec2.z));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
vec2.z = (Math.random() * 0.8 - 0.4) * initialSpeed;
|
vec2.z = (Math.random() * 0.8 - 0.4) * initialSpeed;
|
||||||
vec2.x = Math.sqrt(initialSpeed * initialSpeed - vec2.z * vec2.z);
|
vec2.x = -(speed - Math.abs(vec2.z));
|
||||||
}
|
}
|
||||||
|
|
||||||
onUpdate = false;
|
onUpdate = false;
|
||||||
@ -238,7 +226,7 @@ class Map
|
|||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
ball.material.opacity = 1;
|
ball.material.opacity = 1;
|
||||||
ball.position.set(0, 0.3, 0);
|
ball.position.set(0, 0.3, 0);
|
||||||
speed = 1;
|
speed = 0.4;
|
||||||
|
|
||||||
scoreElement.style.animation = 'fadeOutGames 0.199s';
|
scoreElement.style.animation = 'fadeOutGames 0.199s';
|
||||||
document.getElementsByTagName('canvas')[0].style.filter = 'brightness(1)';
|
document.getElementsByTagName('canvas')[0].style.filter = 'brightness(1)';
|
||||||
|
Reference in New Issue
Block a user