17 Commits

Author SHA1 Message Date
Thomas Fauve-Piot aae651aa8b Front done 2026-03-24 21:02:48 +01:00
Kali Gallon ec560f3447 a faire 2026-03-24 19:38:31 +01:00
Kali Gallon 6df0f24ef6 ^^._, work in progress, small changes 2026-03-24 19:35:13 +01:00
Kali Gallon d8b97ebe17 Merge branch 'LosGringos' into kali 2026-03-24 19:00:32 +01:00
Kali Gallon 98d30c85b2 Merge branch 'LosGringos' of github.com:OlaketalAmigo/Transcendence into LosGringos 2026-03-24 19:00:04 +01:00
Kali Gallon ec36271886 ^^._, work in progress, small changes 2026-03-24 18:58:14 +01:00
Kali Gallon 029c8a6650 ^^._, work in progress, small changes 2026-03-24 18:56:09 +01:00
Thomas Fauve-Piot 0a6e9a25ed Added doodles.png 2026-03-24 18:52:30 +01:00
Kali Gallon e764d565c1 fix merge confict? 2026-03-24 17:02:11 +01:00
Kali Gallon b0fc705d26 ^^._, work in progress, small changes 2026-03-24 15:36:43 +01:00
Thomas Fauve-Piot cb1fc01ad6 Animated but not smooth enough 2026-03-23 23:01:25 +01:00
Kali Gallon 5299f3d1af ^^._, work in progress, small changes 2026-03-20 19:44:08 +01:00
Thomas Fauve-Piot 27704b97f8 Home page's front good 2026-03-20 17:57:00 +01:00
Kali Gallon 2eaae81f28 first impression, i did nothing 2026-03-20 15:16:10 +01:00
Kali Gallon 6f5d27f6a2 ^^._, work in progress, small changes 2026-03-20 15:13:10 +01:00
Thomas Fauve-Piot 938d4cf3b5 45env45 2026-03-20 15:01:39 +01:00
Thomas Fauve-Piot 167896aedd Front started 2026-03-19 23:08:45 +01:00
211 changed files with 1853 additions and 5423 deletions
+10
View File
@@ -0,0 +1,10 @@
POSTGRES_PASSWORD=coucou
JWT_SECRET=superlongsecretkeyatleast32characterspleasenevercommitthis
POSTGRES_DB=database
POSTGRES_HOST=database
POSTGRES_USER=user
GITHUB_CLIENT_ID=Ov23li6ovg3fzec5IO5D
GITHUB_CLIENT_SECRET=0345e959e8f0e9f784061c5c90ee227ddb2ef9ab
GITHUB_CALLBACK_URL=http://localhost:8080/api/auth/github/callback
pogpog
+11 -3
View File
@@ -1,16 +1,24 @@
all : up
all :
@$(call random_shmol_cat, "hELLO", "nice human corrector", $(CLS), )
@docker compose -f ./docker-compose.yml up -d
up :
no_cache :
@docker compose -f ./docker-compose.yml build --no-cache
@docker compose -f ./docker-compose.yml up -d
clean :
@$(call print_cat, $(CLEAR), $(C_225), $(C_320), $(C_450), $(call pad_word, 10, "Objects"), $(call pad_word, 12, "Exterminated"));
@docker compose -f ./docker-compose.yml down -t 1
fclean :
@$(call print_cat, $(CLEAR), $(C_120), $(C_300), $(C_210), $(call pad_word, 10, "Allclean"), $(call pad_word, 12, "Miaster"));
@docker compose -f ./docker-compose.yml down -v -t 1
@docker system prune -af --volumes
re : fclean up
re : fclean no_cache
@$(call print_cat, $(CLEAR), $(C_120), $(C_300), $(C_210), $(call pad_word, 10, "Re-Doing"), $(call pad_word, 12, "Miaster"));
.PHONY : all no_cache clean fclean re
+5 -3
View File
@@ -1,5 +1,5 @@
volumes:
pgdata:
data:
networks:
transcendence:
@@ -12,7 +12,7 @@ services:
ports:
- "5432:5432"
volumes:
- pgdata:/var/lib/postgresql
- data:/var/lib/postgresql/data/pg15/
env_file:
- ../.env
networks:
@@ -24,6 +24,8 @@ services:
build: ./srcs/backend
expose:
- "3001"
# ports:
# - "3001:3001"
depends_on:
- database
volumes:
@@ -38,7 +40,7 @@ services:
container_name: frontend
build: ./srcs/frontend/
ports:
- "8443:443"
- "8080:80"
depends_on:
- backend
networks:
+1 -1
View File
@@ -127,7 +127,7 @@ async function createTables()
status VARCHAR(20) DEFAULT 'waiting',
max_players INT DEFAULT 8,
current_round INT DEFAULT 0,
max_rounds INT DEFAULT 5,
max_rounds INT DEFAULT 3,
round_duration INT DEFAULT 90,
created_at TIMESTAMP DEFAULT NOW(),
started_at TIMESTAMP,
-8
View File
@@ -1,13 +1,5 @@
FROM node:20-alpine
RUN apk add --no-cache openssl
RUN mkdir -p /etc/backend/.ssl
RUN openssl req -x509 -nodes -days 365 -newkey rsa:2048 \
-keyout /etc/backend/.ssl/key.pem \
-out /etc/backend/.ssl/cert.pem \
-subj "/CN=localhost" \
-addext "subjectAltName=DNS:localhost,IP:127.0.0.1"
WORKDIR /app
COPY package*.json ./
+2 -7
View File
@@ -1,6 +1,5 @@
import express from 'express';
import https from 'https';
import fs from 'fs';
import http from 'http';
import cors from 'cors';
import {Server} from 'socket.io';
import authRouter from './routes/auth.js';
@@ -14,11 +13,7 @@ import setupSocketIO from './services/socket.js';
import avatarService from './services/avatar.js';
const app = express();
const httpsOptions = {
key: fs.readFileSync('/etc/backend/.ssl/key.pem'),
cert: fs.readFileSync('/etc/backend/.ssl/cert.pem')
};
const server = https.createServer(httpsOptions, app);
const server = http.createServer(app);
const io = new Server(server,
{
cors:
-11
View File
@@ -26,17 +26,6 @@ router.post('/login', async(req, res) =>
res.status(result.status).json(result.data);
});
router.post('/logout', async(req, res) =>
{
const authHeader = req.headers['authorization'];
const token = authHeader && authHeader.split(' ')[1];
if (!token)
return (res.status(401).json({error: 'Missing token'}));
const result = await authService.logout(token);
res.status(result.status).json(result.data);
});
router.get('/github', (req, res) => {
const githubAuthUrl = `https://github.com/login/oauth/authorize?` +
`client_id=${process.env.GITHUB_CLIENT_ID}&` +
+1 -1
View File
@@ -25,7 +25,7 @@ router.post('/upload', authenticateToken, upload.single('avatar'), async(req, re
res.status(result.status).json(result.data);
});
router.delete('/delete', authenticateToken, async(req, res) =>
router.delete('/', authenticateToken, async(req, res) =>
{
const result = await avatarService.deleteAvatar(req.user.userId);
res.status(result.status).json(result.data);
+1 -25
View File
@@ -2,30 +2,6 @@ import bcrypt from 'bcrypt';
import jwt from 'jsonwebtoken';
import {query} from '../db.js';
async function logout(token)
{
try
{
if (!token)
return ({status: 400, data: {error: 'Missing token'}});
try
{
jwt.verify(token, process.env.JWT_SECRET);
}
catch
{
return ({status: 401, data: {error: 'Invalid token'}});
}
return ({status: 200, data: {message: 'Logged out'}});
}
catch (err)
{
console.error(err);
return ({status: 500, data: {error: 'Server error'}});
}
}
async function login(username, password)
{
try
@@ -84,4 +60,4 @@ async function register(username, password)
}
};
export default {register, login, logout};
export default {register, login};
@@ -69,9 +69,6 @@ async function deleteAvatar(userId) {
if (currentAvatar === null)
return ({status: 404, data: {error: 'User not found'}});
if (currentAvatar === DEFAULT_AVATAR)
return ({status: 400, data: {error: 'Cannot delete default avatar'}});
// Reset the avatar to the default one
await setAvatar(DEFAULT_AVATAR, userId);
+2 -96
View File
@@ -30,63 +30,6 @@ async function broadcastRoomsList(io) {
}
}
function startRoomTimer(io, roomId, seconds)
{
const gameState = gameRooms.get(roomId);
if (!gameState) return;
if (gameState.timerInterval)
clearInterval(gameState.timerInterval);
gameState.timerSeconds = seconds;
gameState.timerInterval = setInterval(() => {
gameState.timerSeconds--;
if (gameState.timerSeconds < 0)
gameState.timerSeconds = 0;
if (gameState.timerSeconds <= 0)
{
io.to(roomId).emit('game-timer-sync', {
remaining: 0
});
clearInterval(gameState.timerInterval);
gameState.timerInterval = null;
io.to(roomId).emit('game-timer-ended', { message: 'Temps écoulé !' });
gameState.currentPlayerIndex = (gameState.currentPlayerIndex + 1) % gameState.players.length;
const nextDrawer = gameState.players[gameState.currentPlayerIndex];
gameState.drawer = nextDrawer;
gameState.currentWord = '';
gameState.revealedLetters = [];
gameState.revealedWord = [];
gameState.guessedLetters = [];
gameState.wrongGuesses = 0;
io.to(roomId).emit('game-new-round', {
drawer: nextDrawer
});
}
else
{
io.to(roomId).emit('game-timer-sync', {
remaining: gameState.timerSeconds
});
}
}, 1000);
}
function stopRoomTimer(roomId)
{
const gameState = gameRooms.get(roomId);
if (!gameState || !gameState.timerInterval) return;
clearInterval(gameState.timerInterval);
gameState.timerInterval = null;
}
// Check if a playing game has only 1 player left and auto-stop it
async function checkAndStopSinglePlayerGame(io, roomId, dbRoomId) {
if (!dbRoomId) return;
@@ -100,7 +43,6 @@ async function checkAndStopSinglePlayerGame(io, roomId, dbRoomId) {
const players = await gameRoomService.getRoomPlayers(dbRoomId);
if (players.length <= 1) {
console.log(`Room ${dbRoomId} has only ${players.length} player(s) left, ending game`);
stopRoomTimer(roomId);
// Update room status to 'ended'
await gameRoomService.updateRoomStatus(dbRoomId, 'waiting');
@@ -250,9 +192,7 @@ function setupSocketIO(io)
revealedLetters: gameState.revealedLetters,
revealedWord: gameState.revealedWord || [],
guessedLetters: gameState.guessedLetters,
players: gameState.players,
scores: gameState.scores || {},
timer: gameState.timerSeconds || 0
players: gameState.players
});
}
});
@@ -262,15 +202,6 @@ function setupSocketIO(io)
if (socket.gameRoomId) {
const roomId = socket.gameRoomId;
const dbRoomId = socket.gameRoomDbId;
const userId = socket.user.userId;
if (dbRoomId && userId) {
try {
await gameRoomService.leaveRoom(dbRoomId, userId);
} catch (err) {
console.error('Error removing player from room on socket leave:', err.message);
}
}
socket.to(roomId).emit('game-player-left', {
username: socket.user.username,
@@ -337,8 +268,7 @@ function setupSocketIO(io)
revealedWord: gameState.revealedWord || [],
guessedLetters: gameState.guessedLetters,
players: gameState.players,
scores: gameState.scores || {},
timer: gameState.timerSeconds || 0
scores: gameState.scores || {}
});
}
} catch (err) {
@@ -460,7 +390,6 @@ function setupSocketIO(io)
const gameState = gameRooms.get(roomId);
if (!gameState) return;
startRoomTimer(io, roomId, 60);
gameState.currentWord = data.word.toLowerCase();
gameState.revealedLetters = new Array(data.word.length).fill(false);
gameState.revealedWord = new Array(data.word.length).fill('_');
@@ -623,8 +552,6 @@ function setupSocketIO(io)
// Update round start scores for next round
gameState.roundStartScores = { ...gameState.scores };
stopRoomTimer(roomId);
io.to(roomId).emit('game-word-found', {
word: gameState.currentWord,
winner: username,
@@ -686,7 +613,6 @@ function setupSocketIO(io)
// If the drawer left and there are still enough players, choose a new drawer
if (wasDrawer && gameState.players.length >= 1)
{
stopRoomTimer(roomId);
// Pick the next player as the new drawer
gameState.currentPlayerIndex = gameState.currentPlayerIndex % gameState.players.length;
const newDrawer = gameState.players[gameState.currentPlayerIndex];
@@ -706,7 +632,6 @@ function setupSocketIO(io)
reason: 'drawer_left',
message: `${username} (dessinateur) a quitté, ${newDrawer} devient le nouveau dessinateur`
});
startRoomTimer(io, roomId, 60);
}
}
@@ -727,7 +652,6 @@ function setupSocketIO(io)
socket.on('game-end', async () => {
const roomId = socket.gameRoomId;
if (!roomId) return;
stopRoomTimer(roomId);
// Update room status to 'waiting' in database
const dbRoomId = socket.gameRoomDbId;
@@ -806,16 +730,6 @@ function setupSocketIO(io)
_tetrisRelayToOpponent(socket, 'tetris:lines-cleared', data);
});
// Relay pur : shield-activated → adversaire uniquement
socket.on('tetris:shield-activated', () => {
_tetrisRelayToOpponent(socket, 'tetris:shield-activated', {});
});
// Relay pur : shield-deactivated → adversaire uniquement
socket.on('tetris:shield-deactivated', () => {
_tetrisRelayToOpponent(socket, 'tetris:shield-deactivated', {});
});
// start-duel → relayé aux DEUX joueurs de la room (inclut l'émetteur)
socket.on('tetris:start-duel', () => {
const code = socket.tetrisRoomCode;
@@ -943,14 +857,6 @@ function setupSocketIO(io)
}
else
{
if (dbRoomId && socket.user.userId) {
try {
await gameRoomService.leaveRoom(dbRoomId, socket.user.userId);
} catch (err) {
console.error('Error removing disconnected player from room:', err.message);
}
}
// Regular player disconnect
socket.to(roomId).emit('game-player-left', {
username: socket.user.username,
+1 -8
View File
@@ -1,12 +1,5 @@
FROM nginx:alpine
RUN apk add --no-cache openssl && \
mkdir -p /etc/nginx/ssl && \
openssl req -x509 -nodes -days 365 -newkey rsa:2048 \
-keyout /etc/nginx/ssl/key.pem \
-out /etc/nginx/ssl/cert.pem \
-subj "/CN=localhost" \
-addext "subjectAltName=DNS:localhost,IP:127.0.0.1"
COPY src /usr/share/nginx/html
COPY nginx.conf /etc/nginx/conf.d/default.conf
EXPOSE 443
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]
+5 -15
View File
@@ -1,9 +1,5 @@
server {
listen 443 ssl;
ssl_certificate /etc/nginx/ssl/cert.pem;
ssl_certificate_key /etc/nginx/ssl/key.pem;
error_page 497 =301 https://$host:8443$request_uri;
listen 80;
root /usr/share/nginx/html;
index index.html;
@@ -15,33 +11,27 @@ server {
# Backend API
location /api/ {
proxy_pass https://backend:3001;
proxy_ssl_verify off;
proxy_pass http://backend:3001;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-Proto https;
}
# Socket.IO WebSocket proxying
location /socket.io/ {
proxy_pass https://backend:3001;
proxy_ssl_verify off;
proxy_pass http://backend:3001;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto https;
proxy_read_timeout 3600s;
proxy_send_timeout 3600s;
proxy_set_header X-Forwarded-Proto $scheme;
}
location /avatar/ {
proxy_pass https://backend:3001/avatar/;
proxy_pass http://backend:3001/avatar/;
proxy_http_version 1.1;
proxy_set_header Host $host;
proxy_ssl_verify off;
proxy_hide_header Content-Type;
add_header Cache-Control "public, max-age=3600";
}
@@ -2,14 +2,13 @@
* Application entry point
* Initializes windows and handles menu interactions
*/
import { windowRegistry } from '../core/windows.js';
import { LoginWindow } from '../windows/login.js';
import { LogoutWindow } from '../windows/logout.js';
import { GlobalChat } from '../windows/global_chat.js';
import { AvatarWindow } from '../windows/avatar.js';
import { FriendsWindow } from '../windows/friends.js';
import { GameRoomWindow } from '../windows/game_room.js';
import { StatsWindow } from '../windows/stats.js';
import { windowRegistry } from './windows.js';
import { LoginWindow } from './login.js';
import { GlobalChat } from './global_chat.js';
import { AvatarWindow } from './avatar.js';
import { FriendsWindow } from './friends.js';
import { GameRoomWindow } from './game_room.js';
import { StatsWindow } from './stats.js';
/**
* Main application class
@@ -17,6 +16,7 @@ import { StatsWindow } from '../windows/stats.js';
*/
class App {
constructor() {
console.log("APP STARTED");
this.initWindows();
this.initMenu();
this.initPage();
@@ -34,7 +34,6 @@ class App {
new FriendsWindow();
new GameRoomWindow();
new StatsWindow();
new LogoutWindow();
}
/**
@@ -52,8 +51,7 @@ class App {
'login': 'login',
'chat': 'chat',
'avatar': 'avatar',
'friends': 'friends',
'logout': 'logout'
'friends': 'friends'
};
// Event delegation on the menu
@@ -78,6 +76,10 @@ class App {
return;
}
const actionMap = {
'gameroom': 'gameroom'
};
// Event delegation on the menu
page.addEventListener('click', (e) => {
const button = e.target.closest('.page__item');
@@ -85,14 +87,9 @@ class App {
const action = button.dataset.action;
if (action === 'gameroom') {
const gameRoomWindow = windowRegistry.get('gameroom');
windowRegistry.toggle('gameroom');
gameRoomWindow.loadRooms();
if (gameRoomWindow?.currentTab === 'browse') {
gameRoomWindow.loadRooms();
}
// Actions with associated windows
if (actionMap[action]) {
windowRegistry.toggle(actionMap[action]);
return;
}
@@ -113,34 +110,34 @@ class App {
colorizeUI() {
const elements = document.querySelectorAll(".title, .menu__item, .game__item, .page__item");
const elements = document.querySelectorAll(".title, .menu__item, .game__item, .page__item");
const colorizeText = (el) => {
const text = el.textContent;
el.innerHTML = "";
const colorizeText = (el) => {
const text = el.textContent;
el.innerHTML = "";
const baseHue = Math.random() * 360;
const baseHue = Math.random() * 360;
// 🎲 random step = makes rainbow "scrambled"
const step = (Math.random() * 60) + 10; // 10 → 70
// 🎲 random step = makes rainbow "scrambled"
const step = (Math.random() * 60) + 10; // 10 → 70
// 🎲 random direction (left or right rainbow)
const direction = Math.random() < 0.5 ? 1 : -1;
// 🎲 random direction (left or right rainbow)
const direction = Math.random() < 0.5 ? 1 : -1;
[...text].forEach((char, i) => {
const span = document.createElement("span");
span.textContent = char;
[...text].forEach((char, i) => {
const span = document.createElement("span");
span.textContent = char;
const hue = baseHue + (i * step * direction);
const hue = baseHue + (i * step * direction);
span.style.color = `hsl(${hue}, 90%, 60%)`;
span.style.color = `hsl(${hue}, 90%, 60%)`;
span.style.textShadow = `1px 1px 0 rgba(0,0,0,0.3)`;
span.style.textShadow = `1px 1px 0 rgba(0,0,0,0.3)`;
el.appendChild(span);
});
};
elements.forEach(colorizeText);
el.appendChild(span);
});
};
elements.forEach(colorizeText);
}
}
@@ -150,4 +147,4 @@ if (document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded', () => new App());
} else {
new App();
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 134 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 134 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 134 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 134 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 134 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 134 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 134 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 134 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 134 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 134 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 134 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 134 KiB

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

Before

Width:  |  Height:  |  Size: 6.2 KiB

After

Width:  |  Height:  |  Size: 6.2 KiB

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 1.4 KiB

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

Before

Width:  |  Height:  |  Size: 1.7 KiB

After

Width:  |  Height:  |  Size: 1.7 KiB

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

Before

Width:  |  Height:  |  Size: 1.0 KiB

After

Width:  |  Height:  |  Size: 1.0 KiB

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

Before

Width:  |  Height:  |  Size: 994 B

After

Width:  |  Height:  |  Size: 994 B

Before

Width:  |  Height:  |  Size: 1018 B

After

Width:  |  Height:  |  Size: 1018 B

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

Before

Width:  |  Height:  |  Size: 955 B

After

Width:  |  Height:  |  Size: 955 B

Before

Width:  |  Height:  |  Size: 1022 B

After

Width:  |  Height:  |  Size: 1022 B

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 1.4 KiB

Before

Width:  |  Height:  |  Size: 887 B

After

Width:  |  Height:  |  Size: 887 B

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

Before

Width:  |  Height:  |  Size: 1000 B

After

Width:  |  Height:  |  Size: 1000 B

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 1.4 KiB

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 MiB

@@ -1,6 +1,6 @@
import { Window, windowRegistry } from '../core/windows.js';
import { API, STORAGE_KEYS, CSS } from '../core/config.js';
import { eventBus, Events } from '../core/events.js';
import { Window, windowRegistry } from './windows.js';
import { API, STORAGE_KEYS, CSS } from './config.js';
import { eventBus, Events } from './events.js';
/**
* Avatar management window
@@ -67,12 +67,8 @@ export class AvatarWindow extends Window {
this.refreshBtn = this.createElement('button', [CSS.BTN, CSS.BTN_SECONDARY], {
text: 'Refresh'
});
this.deleteBtn = this.createElement('button', [CSS.BTN, CSS.BTN_SECONDARY], {
text: 'Delete avatar'
});
this.controls.append(this.statsBtn, this.chooseBtn, this.saveBtn, this.refreshBtn, this.deleteBtn);
this.controls.append(this.statsBtn, this.chooseBtn, this.saveBtn, this.refreshBtn);
// Feedback message
this.message = this.createElement('div', CSS.MESSAGE);
@@ -97,7 +93,6 @@ export class AvatarWindow extends Window {
this.chooseBtn.addEventListener('click', () => this.fileInput.click());
this.saveBtn.addEventListener('click', () => this.uploadAvatar());
this.refreshBtn.addEventListener('click', () => this.loadAvatar());
this.deleteBtn.addEventListener('click', () => this.deleteAvatar());
}
/**
@@ -217,14 +212,12 @@ export class AvatarWindow extends Window {
const token = localStorage.getItem(STORAGE_KEYS.AUTH_TOKEN);
if (!token) {
this.showMessage('You must be logged in', 'error');
this.showNotification('You must be logged in to change your avatar', 'red');
return;
}
const file = this.fileInput.files?.[0];
if (!file) {
this.showMessage('Select an image first', 'error');
this.showNotification('Please select an image to upload', 'red');
return;
}
@@ -247,7 +240,6 @@ export class AvatarWindow extends Window {
if (!response.ok) {
const errorMsg = data?.error || data?.message || 'Upload failed';
this.showMessage(errorMsg, 'error');
this.showNotification('Failed to upload avatar.', 'red');
return;
}
@@ -256,47 +248,11 @@ export class AvatarWindow extends Window {
}
this.showMessage('Avatar saved!', 'success');
this.showNotification('Avatar updated successfully!', 'green');
eventBus.emit(Events.AVATAR_UPDATED, { url: data?.avatar_url });
} catch (error) {
console.error('Avatar upload error:', error);
this.showMessage('Upload error', 'error');
this.showNotification('Failed to upload avatar.', 'red');
}
}
async deleteAvatar() {
const token = localStorage.getItem(STORAGE_KEYS.AUTH_TOKEN);
if (!token) {
this.showMessage('You must be logged in', 'error');
this.showNotification('You must be logged in to delete your avatar', 'red');
return;
}
try {
const response = await fetch(API.AVATAR.DELETE, {
method: 'DELETE',
headers: {
'Authorization': `Bearer ${token}`
}
});
if (!response.ok) {
this.showMessage('Failed to delete avatar', 'error');
this.showNotification('Failed to delete avatar.', 'red');
return;
}
this.preview.src = '';
this.showMessage('Avatar deleted!', 'success');
this.showNotification('Avatar deleted successfully!', 'green');
eventBus.emit(Events.AVATAR_DELETED);
} catch (error) {
console.error('Avatar delete error:', error);
this.showMessage('Delete error', 'error');
this.showNotification('Failed to delete avatar.', 'red');
}
}
@@ -6,14 +6,12 @@
export const API = {
AUTH: {
LOGIN: '/api/auth/login',
LOGOUT: '/api/auth/logout',
REGISTER: '/api/auth/register',
GITHUB: '/api/auth/github'
},
AVATAR: {
GET: '/api/avatar/me',
UPLOAD: '/api/avatar/upload',
DELETE: '/api/avatar/delete'
UPLOAD: '/api/avatar/upload'
},
FRIENDS: {
LIST: '/api/friends',
@@ -0,0 +1,87 @@
.shape {
/* The "Physical" properties */
position: fixed;
/* transform: translate(-50%, -50%); Optional: This makes 'left/top' refer to the CENTER of the doodle */
width: 142px;
height: 142px;
/* The "Stenciling" instructions (but no image yet!) */
-webkit-mask-size: contain;
mask-size: contain;
-webkit-mask-repeat: no-repeat;
mask-repeat: no-repeat;
/* The default "Paint" color */
background-color: white;
}
.shape:hover {
transform: scale(1.2); /* Grow by 20% when you hover the mouse over it */
transition: transform 0.3s ease; /* Make it a smooth grow */
}
/* Individual Doodle Definitions */
.doodle-1 { -webkit-mask-image: url('assets/doodles/ball.png'); mask-image: url('assets/doodles/ball.png'); left: 10vw; top: 10vh; }
.doodle-2 { -webkit-mask-image: url('assets/doodles/batman.png'); mask-image: url('assets/doodles/batman.png'); left: 20vw; top: 15vh; }
.doodle-3 { -webkit-mask-image: url('assets/doodles/building.png'); mask-image: url('assets/doodles/building.png'); left: 30vw; top: 20vh; }
.doodle-4 { -webkit-mask-image: url('assets/doodles/butterfly.png'); mask-image: url('assets/doodles/butterfly.png'); left: 40vw; top: 25vh; }
.doodle-5 { -webkit-mask-image: url('assets/doodles/car.png'); mask-image: url('assets/doodles/car.png'); left: 50vw; top: 30vh; }
.doodle-6 { -webkit-mask-image: url('assets/doodles/cat.png'); mask-image: url('assets/doodles/cat.png'); left: 60vw; top: 35vh; }
.doodle-7 { -webkit-mask-image: url('assets/doodles/clouds.png'); mask-image: url('assets/doodles/clouds.png'); left: 70vw; top: 40vh; }
.doodle-8 { -webkit-mask-image: url('assets/doodles/controls.png'); mask-image: url('assets/doodles/controls.png'); left: 80vw; top: 45vh; }
.doodle-9 { -webkit-mask-image: url('assets/doodles/dead.png'); mask-image: url('assets/doodles/dead.png'); left: 90vw; top: 50vh; }
.doodle-10 { -webkit-mask-image: url('assets/doodles/diamant.png'); mask-image: url('assets/doodles/diamant.png'); left: 15vw; top: 55vh; }
.doodle-11 { -webkit-mask-image: url('assets/doodles/dice.png'); mask-image: url('assets/doodles/dice.png'); left: 25vw; top: 60vh; }
.doodle-12 { -webkit-mask-image: url('assets/doodles/earth.png'); mask-image: url('assets/doodles/earth.png'); left: 35vw; top: 65vh; }
.doodle-13 { -webkit-mask-image: url('assets/doodles/egypt.png'); mask-image: url('assets/doodles/egypt.png'); left: 45vw; top: 70vh; }
.doodle-14 { -webkit-mask-image: url('assets/doodles/fire.png'); mask-image: url('assets/doodles/fire.png'); left: 55vw; top: 75vh; }
.doodle-15 { -webkit-mask-image: url('assets/doodles/fish.png'); mask-image: url('assets/doodles/fish.png'); left: 65vw; top: 80vh; }
.doodle-16 { -webkit-mask-image: url('assets/doodles/flag.png'); mask-image: url('assets/doodles/flag.png'); left: 75vw; top: 85vh; }
.doodle-17 { -webkit-mask-image: url('assets/doodles/hearts.png'); mask-image: url('assets/doodles/hearts.png'); left: 85vw; top: 90vh; }
.doodle-18 { -webkit-mask-image: url('assets/doodles/house.png'); mask-image: url('assets/doodles/house.png'); left: 5vw; top: 45vh; }
.doodle-19 { -webkit-mask-image: url('assets/doodles/idol.png'); mask-image: url('assets/doodles/idol.png'); left: 12vw; top: 22vh; }
.doodle-20 { -webkit-mask-image: url('assets/doodles/lotus.png'); mask-image: url('assets/doodles/lotus.png'); left: 22vw; top: 32vh; }
.doodle-21 { -webkit-mask-image: url('assets/doodles/mail.png'); mask-image: url('assets/doodles/mail.png'); left: 32vw; top: 42vh; }
.doodle-22 { -webkit-mask-image: url('assets/doodles/moon.png'); mask-image: url('assets/doodles/moon.png'); left: 42vw; top: 52vh; }
.doodle-23 { -webkit-mask-image: url('assets/doodles/pokeball.png'); mask-image: url('assets/doodles/pokeball.png'); left: 52vw; top: 62vh; }
.doodle-24 { -webkit-mask-image: url('assets/doodles/runes.png'); mask-image: url('assets/doodles/runes.png'); left: 62vw; top: 72vh; }
.doodle-25 { -webkit-mask-image: url('assets/doodles/shield.png'); mask-image: url('assets/doodles/shield.png'); left: 72vw; top: 82vh; }
.doodle-26 { -webkit-mask-image: url('assets/doodles/shiny.png'); mask-image: url('assets/doodles/shiny.png'); left: 82vw; top: 12vh; }
.doodle-27 { -webkit-mask-image: url('assets/doodles/snail.png'); mask-image: url('assets/doodles/snail.png'); left: 92vw; top: 22vh; }
.doodle-28 { -webkit-mask-image: url('assets/doodles/sound.png'); mask-image: url('assets/doodles/sound.png'); left: 18vw; top: 82vh; }
.doodle-29 { -webkit-mask-image: url('assets/doodles/spiral.png'); mask-image: url('assets/doodles/spiral.png'); left: 28vw; top: 72vh; }
.doodle-30 { -webkit-mask-image: url('assets/doodles/star.png'); mask-image: url('assets/doodles/star.png'); left: 38vw; top: 62vh; }
.doodle-31 { -webkit-mask-image: url('assets/doodles/stop.png'); mask-image: url('assets/doodles/stop.png'); left: 48vw; top: 52vh; }
.doodle-32 { -webkit-mask-image: url('assets/doodles/sun.png'); mask-image: url('assets/doodles/sun.png'); left: 58vw; top: 42vh; }
.doodle-33 { -webkit-mask-image: url('assets/doodles/tree.png'); mask-image: url('assets/doodles/tree.png'); left: 68vw; top: 32vh; }
.doodle-34 { -webkit-mask-image: url('assets/doodles/triskel.png'); mask-image: url('assets/doodles/triskel.png'); left: 78vw; top: 22vh; }
.doodle-35 { -webkit-mask-image: url('assets/doodles/yin_yang.png'); mask-image: url('assets/doodles/yin_yang.png'); left: 88vw; top: 12vh; }
/* 3. A quick animation for the color loop */
.loop-color {
animation: colorShift 12s infinite alternate ease-in-out;
}
@keyframes colorShift {
/* 0% and 100% are identical to create the "Infinite Circle" effect */
0% { background-color: #3075ff; } /* Royal Blue (Start) */
8% { background-color: #24a1ff; } /* Sky Blue */
17% { background-color: #1ad8ff; } /* Cyan */
25% { background-color: #1bffa7; } /* Seafoam Green */
33% { background-color: #1fff4d; } /* Bright Green */
42% { background-color: #8bff32; } /* Lime Green */
50% { background-color: #dcff38; } /* Electric Yellow */
58% { background-color: #ffbc29; } /* Golden Yellow */
67% { background-color: #ff8c4a; } /* Coral Orange */
75% { background-color: #ff1d1d; } /* Hot Red */
83% { background-color: #ff2bf3; } /* Magenta Pink */
92% { background-color: #ac37ff; } /* Electric Purple */
100% { background-color: #3075ff; } /* Royal Blue (Seamless Loop) */
}
+117
View File
@@ -0,0 +1,117 @@
// Function to update a specific shape's color and position
function updateShape(id, x, y, color) {
const element = document.getElementById(id);
if (element) {
element.style.left = x + "px";
element.style.top = y + "px";
element.style.backgroundColor = color;
}
}
// Example usage: Move shape1 to (100, 100) and make it red
// updateShape('shape1', 100, 100, '#ff0000');
function moveRandomly(id) {
const element = document.getElementById(id);
if (!element) return;
// Calculate random coordinates
// We subtract 300 so the shape doesn't go partially off-screen (since your width is 300px)
const maxX = window.innerWidth - 300;
const maxY = window.innerHeight - 300;
const randomX = Math.floor(Math.random() * maxX);
const randomY = Math.floor(Math.random() * maxY);
// Generate a random HEX color
const randomColor = "#" + Math.floor(Math.random()*16777215).toString(16);
// Apply the changes
element.style.left = randomX + "px";
element.style.top = randomY + "px";
element.style.backgroundColor = randomColor;
}
// To make it move every 2 seconds automatically:
// setInterval(() => moveRandomly('shape1'), 2000);
// setInterval(() => moveRandomly('shape2'), 2000);
function startSmoothRandomMove(id, speed = 2) {
const el = document.getElementById(id);
if (!el) return;
// 1. Get initial pixel position or pick random if CSS isn't loaded yet
const rect = el.getBoundingClientRect();
const state = {
x: rect.left || Math.random() * (window.innerWidth - 142),
y: rect.top || Math.random() * (window.innerHeight - 142),
angle: Math.random() * Math.PI * 2,
speed: speed
};
function update() {
// 2. Refresh screen boundaries every frame
const screenW = window.innerWidth;
const screenH = window.innerHeight;
const shapeSize = 142; // Matches your CSS width/height
// 3. Calculate next step
state.x += Math.cos(state.angle) * state.speed;
state.y += Math.sin(state.angle) * state.speed;
// 4. BOUNCE LOGIC (Corrected)
// Horizontal check
if (state.x <= 0) {
state.x = 0;
state.angle = Math.PI - state.angle;
} else if (state.x + shapeSize >= screenW) {
state.x = screenW - shapeSize;
state.angle = Math.PI - state.angle;
}
// Vertical check
if (state.y <= 0) {
state.y = 0;
state.angle = -state.angle;
} else if (state.y + shapeSize >= screenH) {
state.y = screenH - shapeSize;
state.angle = -state.angle;
}
// 5. Apply position using pixels for precision
el.style.left = state.x + "px";
el.style.top = state.y + "px";
requestAnimationFrame(update);
}
requestAnimationFrame(update);
}
// This loop runs 35 times, once for each shape ID
for (let i = 1; i <= 35; i++) {
// Generate a random speed between 1 and 4 for each shape
// so they don't all move at the exact same pace
const randomSpeed = 1 + Math.random() * 3;
// Call your function using the ID 'shape1', 'shape2', etc.
startSmoothRandomMove(`shape${i}`, randomSpeed);
}
function randomizeAnimationStarts() {
const shapes = document.querySelectorAll('.loop-color');
shapes.forEach(shape => {
// Pick a random number between 0 and 10 (since your loop is 10s)
const randomDelay = Math.random() * - 12;
// Apply it directly to the element's style
shape.style.animationDelay = randomDelay + "s";
});
}
// Call this once when the script loads
randomizeAnimationStarts();
@@ -3,20 +3,17 @@
// ─────────────────────────────────────────────
class Duel {
// ui : { showOverlay, hideOverlay, render, renderOpponent, updateButtons }
constructor(socket, tetrisGame, onStatusChange, onStart, ui) {
constructor(socket, tetrisGame, onStatusChange, onStart) {
this.socket = socket;
this.tetrisGame = tetrisGame;
this.onStatusChange = onStatusChange;
this.onStart = onStart;
this.ui = ui;
this.onStatusChange = onStatusChange; // (status, opponentName) => void
this.onStart = onStart; // () => void — déclenche le début du jeu local
this.action_queue = [];
this.opponentGrid = this._emptyGrid();
this.opponentScore = 0;
this.opponentShieldActive = false;
this.roomCode = null;
this.isReady = false;
this.action_queue = [];
this.opponentGrid = this._emptyGrid();
this.opponentScore = 0;
this.roomCode = null;
this.isReady = false;
this._bindSocketEvents();
}
@@ -36,11 +33,10 @@ class Duel {
leave() {
if (!this.roomCode) return;
this.socket.emit('tetris:leave');
this.roomCode = null;
this.isReady = false;
this.opponentGrid = this._emptyGrid();
this.opponentScore = 0;
this.opponentShieldActive = false;
this.roomCode = null;
this.isReady = false;
this.opponentGrid = this._emptyGrid();
this.opponentScore = 0;
}
// ─── Hooks appelés par tetris.js ──────────
@@ -52,7 +48,9 @@ class Duel {
onLocalLinesCleared(count, holeCol) {
if (!this.isReady) return;
const garbageLines = Array.from({ length: count }, () => this._buildGarbageLine(holeCol));
const garbageLines = [];
for (let i = 0; i < count; i++)
garbageLines.push(this._buildGarbageLine(holeCol));
this.socket.emit('tetris:lines-cleared', { count, holeCol, garbageLines });
}
@@ -62,12 +60,6 @@ class Duel {
this.endDuel();
}
onLocalShieldChanged(event) {
if (!this.isReady) return;
if (event === 'activated') this.socket.emit('tetris:shield-activated');
else if (event === 'deactivated') this.socket.emit('tetris:shield-deactivated');
}
endDuel() {
this.isReady = false;
this.action_queue = [];
@@ -78,7 +70,8 @@ class Duel {
synchronize_game() {
while (this.action_queue.length > 0) {
this._processAction(this.action_queue.shift());
const action = this.action_queue.shift();
this._processAction(action);
}
}
@@ -88,7 +81,7 @@ class Duel {
this.opponentGrid = action.grid;
this.opponentScore = action.score;
document.getElementById('opponent-score').textContent = action.score;
this.ui.renderOpponent(this.opponentGrid, this.opponentShieldActive);
renderOpponent(this.opponentGrid);
break;
case 'LINES_CLEARED':
@@ -96,17 +89,9 @@ class Duel {
break;
case 'OPPONENT_GAME_OVER':
this.ui.showOverlay('YOU WIN', action.score);
showOverlay('YOU WIN', action.score);
this.endDuel();
break;
case 'OPPONENT_SHIELD_ACTIVATED':
this.opponentShieldActive = true;
break;
case 'OPPONENT_SHIELD_DEACTIVATED':
this.opponentShieldActive = false;
break;
}
}
@@ -142,36 +127,28 @@ class Duel {
this.action_queue.push({ type: 'OPPONENT_GAME_OVER', score: data.score, validBlock: data.validBlock });
});
this.socket.on('tetris:shield-activated', () => {
this.action_queue.push({ type: 'OPPONENT_SHIELD_ACTIVATED' });
});
this.socket.on('tetris:shield-deactivated', () => {
this.action_queue.push({ type: 'OPPONENT_SHIELD_DEACTIVATED' });
});
this.socket.on('tetris:start-duel', () => {
if (this.onStart) this.onStart();
});
this.socket.on('tetris:pause', () => {
this.tetrisGame.pause();
this.ui.updateButtons();
if (this.tetrisGame.isPaused) this.ui.showOverlay('PAUSE');
else this.ui.hideOverlay();
updateButtons();
if (this.tetrisGame.isPaused) showOverlay('PAUSE');
else hideOverlay();
});
this.socket.on('tetris:stop', () => {
this.tetrisGame.stop();
this.ui.updateButtons();
this.ui.render();
this.ui.showOverlay('STOPPED');
updateButtons();
render();
showOverlay('STOPPED');
});
this.socket.on('tetris:settings', (data) => {
document.getElementById('input-ttd').value = data.timeToDown;
document.getElementById('input-hardening').value = data.hardening;
document.getElementById('input-decrement').value = data.decrementTTD;
document.getElementById('input-ttd').value = data.timeToDown;
document.getElementById('input-hardening').value = data.hardening;
document.getElementById('input-decrement').value = data.decrementTTD;
this.tetrisGame.configure(data);
});
}
@@ -82,7 +82,6 @@ export const Events = {
// Avatar
AVATAR_UPDATED: 'avatar:updated',
AVATAR_DELETED: 'avatar:deleted',
// Chat
CHAT_CONNECTED: 'chat:connected',
Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

@@ -1,6 +1,6 @@
import { Window, windowRegistry } from '../core/windows.js';
import { API, STORAGE_KEYS, CSS } from '../core/config.js';
import { eventBus, Events } from '../core/events.js';
import { Window, windowRegistry } from './windows.js';
import { API, STORAGE_KEYS, CSS } from './config.js';
import { eventBus, Events } from './events.js';
/**
* Friends management window
@@ -120,7 +120,7 @@ body {
.title {
position: absolute;
z-index: 1;
z-index: 999;
top: 20px;
left: 50%;
translate: -50% 0;
+79
View File
@@ -0,0 +1,79 @@
<!doctype html>
<html lang="fr">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Lobby</title>
<link rel="stylesheet" href="doodle.css">
<link rel="stylesheet" href="game.css" />
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
<link href="https://fonts.googleapis.com/css2?family=Cinzel+Decorative:wght@400;700&display=swap" rel="stylesheet" />
<script src="doodle.js" defer></script>
</head>
<script type="module" src="app.js"></script>
<body>
<h1 class="title">
<span>L</span>
<span>o</span>
<span>b</span>
<span>b</span>
<span>y</span>
</h1>
<nav class="menu" aria-label="Menu principal">
<button class="menu__item" data-action="login" aria-label="Login">Login</button>
<button class="menu__item" data-action="chat" aria-label="Global chat">Global chat</button>
<button class="menu__item" data-action="avatar" aria-label="Avatar">Avatar</button>
<button class="menu__item" data-action="friends" aria-label="Amis">Amis</button>
</nav>
<nav class="game" aria-label="Game">
<button class="game__item" data-action="Home page" aria-label="Home Page"
onclick="window.location.href='index.html'">Home Page</button>
</nav>
<div class="page" aria-label="Page">
<button class="page__item" data-action="gameroom" aria-label="Game Rooms">Game Rooms</button>
</div>
<div class="shape doodle-1 loop-color" id="shape1"></div>
<div class="shape doodle-2 loop-color" id="shape2"></div>
<div class="shape doodle-3 loop-color" id="shape3"></div>
<div class="shape doodle-4 loop-color" id="shape4"></div>
<div class="shape doodle-5 loop-color" id="shape5"></div>
<div class="shape doodle-6 loop-color" id="shape6"></div>
<div class="shape doodle-7 loop-color" id="shape7"></div>
<div class="shape doodle-8 loop-color" id="shape8"></div>
<div class="shape doodle-9 loop-color" id="shape9"></div>
<div class="shape doodle-10 loop-color" id="shape10"></div>
<div class="shape doodle-11 loop-color" id="shape11"></div>
<div class="shape doodle-12 loop-color" id="shape12"></div>
<div class="shape doodle-13 loop-color" id="shape13"></div>
<div class="shape doodle-14 loop-color" id="shape14"></div>
<div class="shape doodle-15 loop-color" id="shape15"></div>
<div class="shape doodle-16 loop-color" id="shape16"></div>
<div class="shape doodle-17 loop-color" id="shape17"></div>
<div class="shape doodle-18 loop-color" id="shape18"></div>
<div class="shape doodle-19 loop-color" id="shape19"></div>
<div class="shape doodle-20 loop-color" id="shape20"></div>
<div class="shape doodle-21 loop-color" id="shape21"></div>
<div class="shape doodle-22 loop-color" id="shape22"></div>
<div class="shape doodle-23 loop-color" id="shape23"></div>
<div class="shape doodle-24 loop-color" id="shape24"></div>
<div class="shape doodle-25 loop-color" id="shape25"></div>
<div class="shape doodle-26 loop-color" id="shape26"></div>
<div class="shape doodle-27 loop-color" id="shape27"></div>
<div class="shape doodle-28 loop-color" id="shape28"></div>
<div class="shape doodle-29 loop-color" id="shape29"></div>
<div class="shape doodle-30 loop-color" id="shape30"></div>
<div class="shape doodle-31 loop-color" id="shape31"></div>
<div class="shape doodle-32 loop-color" id="shape32"></div>
<div class="shape doodle-33 loop-color" id="shape33"></div>
<div class="shape doodle-34 loop-color" id="shape34"></div>
<div class="shape doodle-35 loop-color" id="shape35"></div>
</body>
</html>
File diff suppressed because it is too large Load Diff
@@ -1,34 +0,0 @@
<!doctype html>
<html lang="fr">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Lobby</title>
<link rel="stylesheet" href="game.css" />
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
<link href="https://fonts.googleapis.com/css2?family=Cinzel+Decorative:wght@400;700&display=swap" rel="stylesheet" />
</head>
<body>
<h1 class="title">Lobby</h1>
<nav class="menu" aria-label="Menu principal">
<button class="menu__item" data-action="login" aria-label="Login">Login</button>
<button class="menu__item" data-action="chat" aria-label="Global chat">Global chat</button>
<button class="menu__item" data-action="avatar" aria-label="Avatar">Avatar</button>
<button class="menu__item" data-action="friends" aria-label="Amis">Amis</button>
</nav>
<nav class="game" aria-label="Game">
<button class="game__item" data-action="Home page" aria-label="Home Page"
onclick="window.location.href='../index.html'">Home Page</button>
</nav>
<div class="page" aria-label="Page">
<button class="page__item" data-action="gameroom" aria-label="Game Rooms">Game Rooms</button>
</div>
<script type="module" src="../app.js"></script>
</body>
</html>
@@ -1,87 +0,0 @@
.shape {
/* The "Physical" properties */
position: fixed;
/* transform: translate(-50%, -50%); Optional: This makes 'left/top' refer to the CENTER of the doodle */
width: 142px;
height: 142px;
/* The "Stenciling" instructions (but no image yet!) */
-webkit-mask-size: contain;
mask-size: contain;
-webkit-mask-repeat: no-repeat;
mask-repeat: no-repeat;
/* The default "Paint" color */
background-color: white;
}
.shape:hover {
transform: scale(1.2); /* Grow by 20% when you hover the mouse over it */
transition: transform 0.3s ease; /* Make it a smooth grow */
}
/* Individual Doodle Definitions */
.doodle-0 { -webkit-mask-image: url('doodles/cat.png'); mask-image: url('doodles/cat.png'); left: 60vw; top: 35vh; }
.doodle-1 { -webkit-mask-image: url('doodles/ball.png'); mask-image: url('doodles/ball.png'); left: 10vw; top: 10vh; }
.doodle-2 { -webkit-mask-image: url('doodles/batman.png'); mask-image: url('doodles/batman.png'); left: 20vw; top: 15vh; }
.doodle-3 { -webkit-mask-image: url('doodles/building.png'); mask-image: url('doodles/building.png'); left: 30vw; top: 20vh; }
.doodle-4 { -webkit-mask-image: url('doodles/butterfly.png'); mask-image: url('doodles/butterfly.png'); left: 40vw; top: 25vh; }
.doodle-5 { -webkit-mask-image: url('doodles/car.png'); mask-image: url('doodles/car.png'); left: 50vw; top: 30vh; }
.doodle-6 { -webkit-mask-image: url('doodles/yin_yang.png'); mask-image: url('doodles/yin_yang.png'); left: 88vw; top: 12vh; }
.doodle-7 { -webkit-mask-image: url('doodles/clouds.png'); mask-image: url('doodles/clouds.png'); left: 70vw; top: 40vh; }
.doodle-8 { -webkit-mask-image: url('doodles/controls.png'); mask-image: url('doodles/controls.png'); left: 80vw; top: 45vh; }
.doodle-9 { -webkit-mask-image: url('doodles/dead.png'); mask-image: url('doodles/dead.png'); left: 90vw; top: 50vh; }
.doodle-10 { -webkit-mask-image: url('doodles/diamant.png'); mask-image: url('doodles/diamant.png'); left: 15vw; top: 55vh; }
.doodle-11 { -webkit-mask-image: url('doodles/dice.png'); mask-image: url('doodles/dice.png'); left: 25vw; top: 60vh; }
.doodle-12 { -webkit-mask-image: url('doodles/earth.png'); mask-image: url('doodles/earth.png'); left: 35vw; top: 65vh; }
.doodle-13 { -webkit-mask-image: url('doodles/egypt.png'); mask-image: url('doodles/egypt.png'); left: 45vw; top: 70vh; }
.doodle-14 { -webkit-mask-image: url('doodles/fire.png'); mask-image: url('doodles/fire.png'); left: 55vw; top: 75vh; }
.doodle-15 { -webkit-mask-image: url('doodles/fish.png'); mask-image: url('doodles/fish.png'); left: 65vw; top: 80vh; }
.doodle-16 { -webkit-mask-image: url('doodles/flag.png'); mask-image: url('doodles/flag.png'); left: 75vw; top: 85vh; }
.doodle-17 { -webkit-mask-image: url('doodles/hearts.png'); mask-image: url('doodles/hearts.png'); left: 85vw; top: 90vh; }
.doodle-18 { -webkit-mask-image: url('doodles/house.png'); mask-image: url('doodles/house.png'); left: 5vw; top: 45vh; }
.doodle-19 { -webkit-mask-image: url('doodles/idol.png'); mask-image: url('doodles/idol.png'); left: 12vw; top: 22vh; }
.doodle-20 { -webkit-mask-image: url('doodles/lotus.png'); mask-image: url('doodles/lotus.png'); left: 22vw; top: 32vh; }
.doodle-21 { -webkit-mask-image: url('doodles/mail.png'); mask-image: url('doodles/mail.png'); left: 32vw; top: 42vh; }
.doodle-22 { -webkit-mask-image: url('doodles/moon.png'); mask-image: url('doodles/moon.png'); left: 42vw; top: 52vh; }
.doodle-23 { -webkit-mask-image: url('doodles/pokeball.png'); mask-image: url('doodles/pokeball.png'); left: 52vw; top: 62vh; }
.doodle-24 { -webkit-mask-image: url('doodles/runes.png'); mask-image: url('doodles/runes.png'); left: 62vw; top: 72vh; }
.doodle-25 { -webkit-mask-image: url('doodles/shield.png'); mask-image: url('doodles/shield.png'); left: 72vw; top: 82vh; }
.doodle-26 { -webkit-mask-image: url('doodles/shiny.png'); mask-image: url('doodles/shiny.png'); left: 82vw; top: 12vh; }
.doodle-27 { -webkit-mask-image: url('doodles/snail.png'); mask-image: url('doodles/snail.png'); left: 92vw; top: 22vh; }
.doodle-28 { -webkit-mask-image: url('doodles/sound.png'); mask-image: url('doodles/sound.png'); left: 18vw; top: 82vh; }
.doodle-29 { -webkit-mask-image: url('doodles/spiral.png'); mask-image: url('doodles/spiral.png'); left: 28vw; top: 72vh; }
.doodle-30 { -webkit-mask-image: url('doodles/star.png'); mask-image: url('doodles/star.png'); left: 38vw; top: 62vh; }
.doodle-31 { -webkit-mask-image: url('doodles/stop.png'); mask-image: url('doodles/stop.png'); left: 48vw; top: 52vh; }
.doodle-32 { -webkit-mask-image: url('doodles/sun.png'); mask-image: url('doodles/sun.png'); left: 58vw; top: 42vh; }
.doodle-33 { -webkit-mask-image: url('doodles/tree.png'); mask-image: url('doodles/tree.png'); left: 68vw; top: 32vh; }
.doodle-34 { -webkit-mask-image: url('doodles/triskel.png'); mask-image: url('doodles/triskel.png'); left: 78vw; top: 22vh; }
/* 3. A quick animation for the color loop */
.loop-color {
animation: colorShift 12s infinite alternate ease-in-out;
}
@keyframes colorShift {
/* 0% and 100% are identical to create the "Infinite Circle" effect */
0% { background-color: #3075ff; } /* Royal Blue (Start) */
8% { background-color: #24a1ff; } /* Sky Blue */
17% { background-color: #1ad8ff; } /* Cyan */
25% { background-color: #1bffa7; } /* Seafoam Green */
33% { background-color: #1fff4d; } /* Bright Green */
42% { background-color: #8bff32; } /* Lime Green */
50% { background-color: #dcff38; } /* Electric Yellow */
58% { background-color: #ffbc29; } /* Golden Yellow */
67% { background-color: #ff8c4a; } /* Coral Orange */
75% { background-color: #ff1d1d; } /* Hot Red */
83% { background-color: #ff2bf3; } /* Magenta Pink */
92% { background-color: #ac37ff; } /* Electric Purple */
100% { background-color: #3075ff; } /* Royal Blue (Seamless Loop) */
}
@@ -1,113 +0,0 @@
const maxdoodles = 34;
// /////////////////////////////////////////////////////////////////////////////////////////>\
// container for all doodles, create them
class DoodleContainer {
constructor(parent) {
this.parent = parent;
this.obj = document.createElement('div');
Object.assign(this.obj.style, {
width: '100vw',
height: '100vw',
});
this.createAllDoodles();
parent.append(this.obj);
this.randomizeAnimationStarts();
}
createAllDoodles() {
for (let i = 0; i <= maxdoodles; i++) {
let d = document.createElement('div');
d.classList.add('shape', 'doodle-' + i, 'loop-color');
d.id = 'shape' + i;
this.obj.append(d);
d.addEventListener('click', () => {
console.log(`hi from ${d.id}!`);
})
}
}
startSmoothRandomMove(id, speed = 2) {
const el = document.getElementById(id);
if (!el)
return;
// 1. Get initial pixel position or pick random if CSS isn't loaded yet
const rect = el.getBoundingClientRect();
const state = {
x: rect.left || Math.random() * (window.innerWidth - 142),
y: rect.top || Math.random() * (window.innerHeight - 142),
angle: Math.random() * Math.PI * 2,
speed: speed
};
function update() {
// 2. Refresh screen boundaries every frame
const screenW = window.innerWidth;
const screenH = window.innerHeight;
const shapeSize = 142; // Matches your CSS width/height
// 3. Calculate next step
state.x += Math.cos(state.angle) * state.speed;
state.y += Math.sin(state.angle) * state.speed;
// 4. BOUNCE LOGIC
// Horizontal check
if (state.x <= 0) {
state.x = 0;
state.angle = Math.PI - state.angle;
} else if (state.x + shapeSize >= screenW) {
state.x = screenW - shapeSize;
state.angle = Math.PI - state.angle;
}
// Vertical check
if (state.y <= 0) {
state.y = 0;
state.angle = -state.angle;
} else if (state.y + shapeSize >= screenH) {
state.y = screenH - shapeSize;
state.angle = -state.angle;
}
// 5. Apply position using pixels for precision
el.style.left = state.x + "px";
el.style.top = state.y + "px";
requestAnimationFrame(update);
}
requestAnimationFrame(update);
}
randomizeAnimationStarts() {
for (let i = 0; i <= maxdoodles; i++) {
const randomSpeed = 1 + Math.random() * 3;
this.startSmoothRandomMove(`shape${i}`, randomSpeed);
}
}
}
// /////////////////////////////////////////////////////////////////////////////////////////>
// all loop-color have the same @colorShift animation cycle, this disynchronize them
function randomizeColorsStarts() {
const shapes = document.querySelectorAll('.loop-color');
shapes.forEach(shape => {
// Pick a random number between 0 and 10 (since your loop is 10s)
const randomDelay = Math.random() * - 15;
// Apply it directly to the element's style
shape.style.animationDelay = randomDelay + "s";
});
}
const a = new DoodleContainer(document.body);
// Call this once when the script loads
randomizeColorsStarts();
@@ -1,43 +0,0 @@
<!doctype html>
<html lang="fr">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Lobby</title>
<link rel="stylesheet" href="doodle.css">
<link rel="stylesheet" href="game.css" />
<!-- <link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
<link href="https://fonts.googleapis.com/css2?family=Cinzel+Decorative:wght@400;700&display=swap" rel="stylesheet" /> -->
<script src="doodle.js" defer></script>
<script type="module" src="../trans/app.js"></script>
</head>
<body>
<h1 class="title">
<span>L</span>
<span>o</span>
<span>b</span>
<span>b</span>
<span>y</span>
</h1>
<nav class="menu" aria-label="Menu principal">
<button class="menu__item" data-action="login" aria-label="Login">Login</button>
<button class="menu__item" data-action="chat" aria-label="Global chat">Global chat</button>
<button class="menu__item" data-action="avatar" aria-label="Avatar">Avatar</button>
<button class="menu__item" data-action="friends" aria-label="Amis">Amis</button>
</nav>
<nav class="game" aria-label="Game">
<button class="game__item" data-action="Home page" aria-label="Home Page"
onclick="window.location.href='index.html'">Home Page</button>
</nav>
<div class="page" aria-label="Page">
<button class="page__item" data-action="gameroom" aria-label="Game Rooms">Game Rooms</button>
</div>
</body>
</html>
@@ -1,6 +1,6 @@
import { Window } from '../core/windows.js';
import { API, STORAGE_KEYS, CSS } from '../core/config.js';
import { eventBus, Events } from '../core/events.js';
import { Window } from './windows.js';
import { API, STORAGE_KEYS, CSS } from './config.js';
import { eventBus, Events } from './events.js';
export class GameRoomWindow extends Window {
constructor() {
@@ -34,7 +34,6 @@ export class GameRoomWindow extends Window {
});
this.updateTabsAccess();
this.loadCurrentTab();
// Verifier si l'utilisateur est deja dans un salon au chargement
const token = localStorage.getItem(STORAGE_KEYS.AUTH_TOKEN);
@@ -120,8 +119,7 @@ export class GameRoomWindow extends Window {
this.gameInfo = this.createElement('div', 'gameroom__game-info');
this.currentDrawerInfo = this.createElement('div', 'gameroom__drawer-info', { text: '' });
this.scoresDisplay = this.createElement('div', 'gameroom__scores-display');
this.timerDisplay = this.createElement('div', 'gameroom__timer-display');
this.gameInfo.append(this.currentDrawerInfo, this.scoresDisplay, this.timerDisplay);
this.gameInfo.append(this.currentDrawerInfo, this.scoresDisplay);
// Affichage du mot caché
this.wordDisplay = this.createElement('div', 'gameroom__word-display');
@@ -196,10 +194,7 @@ export class GameRoomWindow extends Window {
players: [],
currentPlayerIndex: 0,
guessedLetters: [],
scores: {},
counter: 0,
counterRound: 0,
timer: 0
scores: {}
};
this.initDrawing();
@@ -379,11 +374,10 @@ export class GameRoomWindow extends Window {
this.socket.on('game-player-left', (data) => {
this.showMessage(`${data.username} a quitté le salon`, 'info');
console.log(`${data.username} left the room`);
if (this.gameState.isPlaying)
{
if (Array.isArray(this.gameState.players))
if (this.gameState.players)
this.gameState.players = this.gameState.players.filter(p => p !== data.username);
}
@@ -499,7 +493,7 @@ export class GameRoomWindow extends Window {
// If spectating, return to spectator list
if (this.isSpectating) {
this.resetGameUI();
// this.currentRoom = null;
this.currentRoom = null;
this.isSpectating = false;
this.switchTab('spectator');
this.showMessage('La partie est terminée', 'info');
@@ -524,8 +518,6 @@ export class GameRoomWindow extends Window {
this.gameState.revealedWord = data.revealedWord || new Array(data.wordLength).fill('_');
this.gameState.players = data.players;
this.gameState.scores = data.scores || {};
this.gameState.timer = data.timer || 0;
this.updateTimerUI();
this.showGameUI();
this.updateWordDisplay();
@@ -615,15 +607,6 @@ export class GameRoomWindow extends Window {
// Setup UI for new round with new drawer
this.setupRound();
});
this.socket.on('game-timer-sync', (data) => {
this.gameState.timer = data.remaining;
this.updateTimerUI();
});
this.socket.on('game-timer-ended', (data) => {
this.showMessage(data.message || 'Temps écoulé !', 'info');
})
}
disconnectGameSocket() {
@@ -734,7 +717,7 @@ export class GameRoomWindow extends Window {
const altPort = window.GLOBAL_CHAT_ALT_PORT;
if (altPort) {
const host = location.hostname || 'localhost';
this.socket = io(`${location.protocol}//${host}:${altPort}`, ioConfig);
this.socket = io(`http://${host}:${altPort}`, ioConfig);
} else {
this.socket = io(ioConfig);
}
@@ -768,7 +751,8 @@ export class GameRoomWindow extends Window {
return;
}
this.renderRoomsList(data || []);
this.roomsList = data || [];
this.renderRoomsList(this.roomsList);
} catch (error) {
console.error('Load rooms error:', error);
this.showMessage('Erreur de connexion', 'error');
@@ -855,20 +839,17 @@ export class GameRoomWindow extends Window {
const name = this.roomNameInput.value.trim();
if (!name) {
this.showMessage('Entrez un nom pour le salon', 'error');
this.showNotification('Entrez un nom pour le salon', 'red');
return;
}
const token = localStorage.getItem(STORAGE_KEYS.AUTH_TOKEN);
if (!token) {
this.showMessage('Connectez-vous pour creer un salon', 'info');
this.showNotification('Connectez-vous pour créer un salon', 'red');
return;
}
if (this.currentRoom) {
this.showMessage('Vous etes deja dans un salon. Quittez-le d\'abord.', 'error');
this.showNotification('Vous êtes déjà dans un salon. Quittez-le d\'abord.', 'red');
return;
}
@@ -882,7 +863,6 @@ export class GameRoomWindow extends Window {
this.currentRoom = currentData;
this.enterLobby(currentData);
this.showMessage('Vous etes deja dans un salon', 'error');
this.showNotification('Vous êtes déjà dans un salon. Quittez-le d\'abord.', 'red');
return;
}
}
@@ -903,7 +883,6 @@ export class GameRoomWindow extends Window {
if (this.roomNameExists(name)) {
this.showMessage('Un salon avec ce nom existe deja', 'error');
this.showNotification('Un salon avec ce nom existe deja', 'red');
return;
}
@@ -925,7 +904,6 @@ export class GameRoomWindow extends Window {
this.showMessage('Salon cree', 'success');
eventBus.emit(Events.ROOM_CREATED, data);
this.enterLobby(data);
this.showNotification(`Vous avez créé le salon "${data.name}"`, 'green');
} catch (error) {
console.error('Create room error:', error);
this.showMessage('Erreur de connexion', 'error');
@@ -1058,7 +1036,6 @@ export class GameRoomWindow extends Window {
if (this.currentRoom) {
this.showMessage('Vous etes deja dans un salon. Quittez-le d\'abord.', 'error');
this.showNotification('Vous êtes déjà dans un salon. Quittez-le d\'abord.', 'red');
return;
}
@@ -1072,7 +1049,6 @@ export class GameRoomWindow extends Window {
this.currentRoom = currentData;
this.enterLobby(currentData);
this.showMessage('Vous etes deja dans un salon', 'error');
this.showNotification('Vous êtes déjà dans un salon. Quittez-le d\'abord.', 'red');
return;
}
}
@@ -1117,9 +1093,7 @@ export class GameRoomWindow extends Window {
}
async loadLobby() {
console.log('Loading lobby for room:', this.currentRoom);
if (!this.currentRoom) return;
console.log('Managed to load lobby, current room:', this.currentRoom);
this.gameState.scores = {};
@@ -1258,12 +1232,6 @@ export class GameRoomWindow extends Window {
}, 5000);
}
updateTimerUI()
{
if (this.timerDisplay)
this.timerDisplay.textContent = `Temps restant : ${this.gameState.timer}s`;
}
// ============================================
// LOGIQUE DU JEU
// ============================================
@@ -1318,9 +1286,6 @@ export class GameRoomWindow extends Window {
this.isSpectating = false;
this.gameState.scores = {};
this.gameState.counter = 0;
this.gameState.counterRound = 0;
this.gameState.timer = 0;
this.gameState.players = [];
this.gameState.currentPlayerIndex = 0;
this.gameState.guessedLetters = [];
@@ -1544,7 +1509,7 @@ export class GameRoomWindow extends Window {
const pointsText = points !== 0 ? ` (${points > 0 ? '+' : ''}${points} pts)` : '';
if (success) {
item.textContent = `${username}: "${guess}" - Bon ${typeText}!${pointsText}`;
item.textContent = `${username}: "${guess}" - Bonne ${typeText}!${pointsText}`;
} else {
item.textContent = `${username}: "${guess}" - Mauvais ${typeText}${pointsText}`;
}
@@ -1594,10 +1559,7 @@ export class GameRoomWindow extends Window {
this.wordDisplay.textContent = word.split('').join(' ');
// Auto next round after delay
this.gameState.counterRound++;
setTimeout(() => {
if (this.gameState.counterRound >= (this.gameState.players.length * 4))
this.endGame();
if (this.gameState.isPlaying) {
this.nextRound();
}
@@ -1606,11 +1568,8 @@ export class GameRoomWindow extends Window {
nextRound() {
// Move to next player
this.gameState.counter++;
if (this.gameState.counter >= this.gameState.players.length) {
this.gameState.counter = 0;
}
const nextDrawer = this.gameState.players[this.gameState.counter];
this.gameState.currentPlayerIndex = (this.gameState.currentPlayerIndex + 1) % this.gameState.players.length;
const nextDrawer = this.gameState.players[this.gameState.currentPlayerIndex];
if (this.socket?.connected) {
this.socket.emit('game-next-round', { drawer: nextDrawer });
@@ -1,6 +1,6 @@
import { Window } from '../core/windows.js';
import { STORAGE_KEYS, CSS } from '../core/config.js';
import { eventBus, Events } from '../core/events.js';
import { Window } from './windows.js';
import { STORAGE_KEYS, CSS } from './config.js';
import { eventBus, Events } from './events.js';
/**
* Global chat window
@@ -222,7 +222,7 @@ export class GlobalChat extends Window {
const altPort = window.GLOBAL_CHAT_ALT_PORT;
if (altPort) {
const host = location.hostname || 'localhost';
this.socket = io(`${location.protocol}//${host}:${altPort}`, ioConfig);
this.socket = io(`http://${host}:${altPort}`, ioConfig);
} else {
this.socket = io(ioConfig);
}
+729 -134
View File
@@ -1,157 +1,752 @@
/* ============================================
TRANSCENDENCE - Main Stylesheet
Convention: BEM (Block__Element--Modifier)
============================================ */
/* ///////////////////////////////////////////////////////// */
/* ============================================
CSS VARIABLES
============================================ */
:root {
--custom-value: hello;
--color-primary: #ffc75e;
--color-primary-hover: #ffc75e;
--color-success: #3cff01;
--color-success-dark: #ffc75e;
--color-error: #ff4d4d;
--color-warning: #ffc75e;
--color-github: #ffc75e;
--color-bg: #ffe5b5;
--app-background-base: radial-gradient(
circle at top,
#000000,
#4d4d4d
#fff787,
#ff8080
);
--app-background-image: url("./assets/background.png");
--num-value: 10px;
--black: #000000;
--color-surface: #ffefce;
--color-surface-light: #ffc75e;
--color-text: #000000;
--color-text-muted: #000000;
--font-size-base: 10px;
--font-size-sm: 1.2rem;
--font-size-md: 1.4rem;
--font-size-lg: 1.6rem;
--font-size-xl: 3rem;
--spacing-xs: 4px;
--spacing-sm: 8px;
--spacing-md: 12px;
--spacing-lg: 16px;
--spacing-xl: 24px;
--radius-sm: 4px;
--radius-md: 6px;
--radius-lg: 12px;
--radius-full: 50%;
--shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.3);
--shadow-md: 0 4px 8px rgba(0, 0, 0, 0.5);
--shadow-lg: 0 8px 16px rgba(0, 0, 0, 0.5);
--transition-fast: 150ms ease;
--transition-normal: 250ms ease;
--z-menu: 2;
--z-window: 100;
--z-modal: 200;
}
/* ///////////////////////////////////////////////////////// */
*, *::before, *::after {
/* ============================================
RESET & BASE
============================================ */
*,
*::before,
*::after {
box-sizing: border-box;
}
html {
height: 100%;
background-image:
var(--app-background-image),
var(--app-background-base);
background-size:
contain,
cover;
background-position:
center,
center;
background-repeat:
no-repeat,
no-repeat;
}
body {
line-height: 1.5; /* inherited */
word-spacing: 1.4px; /* inherited */
font-size: 20px;
font-family: 'Times New Roman', serif; /* inherited */
color: var(--black); /* inherited */
text-align: center;
color: #696969;
margin: 0;
padding: 0;
background-color: var(--black);
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
margin: 0;
width: 70%;
min-width: 800px;
margin: 0 auto;
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
color: var(--color-text);
line-height: 1.5;
}
.container-1 {
display: flex;
justify-content: center;
align-items: center;
/* ============================================
TYPOGRAPHY
============================================ */
.title {
position: absolute;
top: 20px;
left: 50%;
transform: translateX(-50%);
text-transform: uppercase;
width: 100%;
margin: 5px;
position: relative;
min-height: 200px;
}
/* ///////////////////////////////////////////////////////// */
.button {
color: red;
margin: 5px 50px;
padding: 5px 50px;
}
.button-1 {
display: inline-block;
padding: 10px 20px;
background-color: #000000;
color: #8e8e8e;
text-align: center;
text-decoration: none;
font-size: 16px;
cursor: pointer;
border: 3px solid #363636;
border-radius: 6px;
transition: background-color 0.3s;
}
.button-1:hover {
background-color: rgb(202, 135, 10);
color: black;
}
/* ///////////////////////////////////////////////////////// */
.button-trans {
/* SIZE */
position: absolute;
left: 50%;
transform: translateX(-50%);
width: 500px;
height: 200px;
/* TEXT */
font-family: "Roboto";
font-size: 62px;
letter-spacing: -10px;
display: flex;
align-items: center;
justify-content: center;
/* Background */
background-image: url("./assets/background.png");
background-position: center;
background-repeat: no-repeat;
background-size: 150%;
/* Borders */
border-radius: 20px;
border-radius: 20px;
border: 5px solid transparent; /* keep space for the shadow */
background-clip: padding-box;
/* metallic effect */
box-shadow:
0 0 0 5px #c0c0c0 inset, /* inner shine */
0 0 0 2px rgba(255,255,255,0.3) inset; /* subtle highlight */
/* OTHER */
cursor: pointer;
transition: transform 0.3s ease, box-shadow 0.3s ease;
}
.button-trans:hover {
transform: translateX(-50%) scale(1.02);
box-shadow:
0 0 20px 5px #fff inset,
0 0 20px 5px rgba(255,255,255,0.3) inset;
}
/* ///////////////////////////////////////////////////////// */
.button-test {
margin-right: auto;
margin-left: 20px;
}
/* ///////////////////////////////////////////////////////// */
.footer_div {
display: flex;
justify-content: space-around;
/* padding: 20px; */
/* margin-top: 80px;
margin-bottom: 100px; */
}
align-items: center;
justify-content: center;
gap: 20px;
.ico_footer {
font-size: var(--font-size-xl);
text-align: center;
width: 25px;
vertical-align: top;
/* padding-right: 5px; */
}
a {
text-decoration: none;
color: #5c5c5c;
}
a:hover {
color: rgb(218, 145, 12);
text-shadow: 2px 2px 10px black;
z-index: 1;
font-family: "Roboto";
letter-spacing: -10px;
color: rgba(248, 252, 2, 0.6);
margin: 0;
padding: 0.6rem 1.2rem;
background-color: #ffefce;
border: 2px solid rgba(0, 0, 0, 0.6);
border-radius: var(--radius-lg);
}
/* ///////////////////////////////////////////////////////// */
/* ============================================
MENU
============================================ */
.menu {
position: fixed;
top: var(--spacing-lg);
left: 50px;
display: flex;
flex-direction: column;
gap: var(--spacing-lg);
z-index: var(--z-menu);
}
.menu__item {
background: var(--color-surface);
color: var(--color-text);
border: 1px solid var(--color-surface-light);
border-radius: var(--radius-lg);
border-color: #000;
padding: var(--spacing-sm) var(--spacing-md);
font-size: var(--font-size-md);
cursor: pointer;
transition: all var(--transition-fast);
text-align: center;
}
.menu__item:hover {
background: var(--color-surface-light);
font-size: var(--font-size-lg);
}
.menu__item--active {
background: var(--color-primary);
border-color: var(--color-primary);
}
/* ============================================
GAME
============================================ */
/* .game {
position: fixed;
top: 0;
right: 50px;
padding: 0;
margin: 0;
z-index: var(--z-menu);
display: flex;
flex-direction: column;
gap: var(--spacing-xs);
} */
.game {
position: fixed;
top: var(--spacing-lg);
right: 50px;
display: flex;
flex-direction: column;
gap: var(--spacing-lg);
z-index: var(--z-menu);
}
.game__item {
background: var(--color-surface);
color: var(--color-text);
border: 1px solid var(--color-surface-light);
border-radius: var(--radius-lg);
border-color: #000;
padding: var(--spacing-sm) var(--spacing-md);
font-size: var(--font-size-md);
cursor: pointer;
transition: all var(--transition-fast);
text-align: center;
}
.game__item:hover {
background: var(--color-surface-light);
font-size: var(--font-size-lg);
}
.game__item--active {
background: var(--color-primary);
border-color: var(--color-primary);
}
/* ============================================
BUTTONS
============================================ */
.btn {
display: inline-flex;
align-items: center;
justify-content: center;
padding: var(--spacing-sm) var(--spacing-md);
font-size: var(--font-size-md);
font-weight: 500;
border: none;
border-radius: var(--radius-md);
cursor: pointer;
transition: all var(--transition-fast);
text-decoration: none;
}
.btn:hover {
opacity: 0.9;
transform: translateY(-1px);
}
.btn:active {
transform: translateY(0);
}
.btn--primary {
background: var(--color-primary);
color: var(--color-text);
}
.btn--primary:hover {
background: var(--color-primary-hover);
}
.btn--secondary {
background: var(--color-surface-light);
color: var(--color-text);
}
.btn--success {
background: var(--color-success-dark);
color: var(--color-text);
}
.btn--danger {
background: var(--color-error);
color: var(--color-text);
}
.btn--github {
background: var(--color-github);
color: var(--color-text);
}
.btn--ghost {
background: transparent;
color: var(--color-text);
border: 1px solid var(--color-surface-light);
}
/* ============================================
INPUTS
============================================ */
.input {
width: 100%;
padding: var(--spacing-sm) var(--spacing-md);
font-size: var(--font-size-md);
background: var(--color-surface);
color: var(--color-text);
border: 1px solid var(--color-surface-light);
border-radius: var(--radius-md);
transition: border-color var(--transition-fast);
}
.input:focus {
outline: none;
border-color: var(--color-primary);
}
.input::placeholder {
color: var(--color-text-muted);
}
.input-group {
display: flex;
flex-direction: column;
gap: var(--spacing-sm);
}
/* ============================================
WINDOWS
============================================ */
.window {
position: fixed;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
background: var(--color-bg);
color: var(--color-text);
z-index: var(--z-window);
display: none;
flex-direction: column;
min-width: 280px;
box-shadow: var(--shadow-lg);
border-radius: 5px;
border-color: #aa1f1f;
border: 6px solid #faac37;
}
.window--visible {
display: flex;
}
.window--left {
left: 25%;
}
.window--right {
left: 75%;
}
.window__header {
display: flex;
justify-content: space-between;
align-items: center;
padding: var(--spacing-sm) var(--spacing-md);
background: var(--color-surface);
cursor: move;
user-select: none;
}
.window__title {
font-weight: 500;
font-size: var(--font-size-md);
}
.window__close {
cursor: pointer;
font-size: var(--font-size-lg);
opacity: 0.8;
transition: opacity var(--transition-fast);
background: none;
border: none;
color: var(--color-text);
padding: 0;
line-height: 1;
}
.window__close:hover {
opacity: 1;
}
.window__body {
padding: var(--spacing-md);
display: flex;
flex-direction: column;
gap: var(--spacing-sm);
flex: 1;
overflow: auto;
}
/* ============================================
MESSAGES
============================================ */
.message {
font-size: var(--font-size-sm);
padding: var(--spacing-xs);
border-radius: var(--radius-lg);
border-color: #000;
}
.message--success {
color: var(--color-success);
}
.message--error {
color: var(--color-error);
}
.message--info {
color: var(--color-text-muted);
}
/* ============================================
LOGIN WINDOW
============================================ */
.login {
width: 320px;
border-radius: 5px;
border-color: #aa1f1f;
border: 6px solid #faac37;
background: #ffffff;
color: #000;
}
.login__form {
display: flex;
flex-direction: column;
gap: var(--spacing-sm);
}
.login__actions {
display: flex;
gap: var(--spacing-sm);
margin-top: var(--spacing-xs);
}
.login__divider {
display: flex;
align-items: center;
gap: var(--spacing-sm);
color: var(--color-text-muted);
font-size: var(--font-size-sm);
margin: var(--spacing-sm) 0;
}
.login__divider::before,
.login__divider::after {
content: '';
flex: 1;
height: 1px;
background: var(--color-surface-light);
}
/* ============================================
CHAT WINDOW
============================================ */
.chat {
width: 380px;
height: 400px;
}
.chat__output {
flex: 1;
overflow-y: auto;
padding: var(--spacing-sm);
background: var(--color-surface);
border-radius: var(--radius-md);
display: flex;
flex-direction: column;
gap: var(--spacing-sm);
min-height: 150px;
}
.chat__message {
padding: var(--spacing-xs) var(--spacing-sm);
background: var(--color-surface-light);
border-radius: var(--radius-sm);
font-size: var(--font-size-sm);
}
.chat__message--own {
background: var(--color-primary);
align-self: flex-end;
}
.chat__friend-indicator {
display: inline-block;
width: 8px;
height: 8px;
background-color: var(--color-success);
border-radius: 50%;
margin-right: var(--spacing-xs);
vertical-align: middle;
}
.chat__system {
color: var(--color-text-muted);
font-size: var(--font-size-sm);
font-style: italic;
text-align: center;
}
.chat__system--error {
color: var(--color-error);
}
.chat__system--success {
color: var(--color-success);
}
.chat__input-container {
display: flex;
gap: var(--spacing-sm);
margin-top: var(--spacing-sm);
}
.chat__input {
flex: 1;
}
.chat__controls {
display: flex;
gap: var(--spacing-sm);
margin-top: var(--spacing-sm);
}
/* ============================================
AVATAR WINDOW
============================================ */
.avatar-window {
width: 360px;
}
.avatar__preview {
width: 120px;
height: 120px;
object-fit: cover;
border-radius: var(--radius-full);
border: 3px solid var(--color-text);
box-shadow: var(--shadow-md);
background: var(--color-surface);
align-self: center;
}
.avatar__username {
font-size: var(--font-size-lg);
font-weight: 600;
text-align: center;
color: var(--color-text);
margin-top: var(--spacing-sm);
}
.avatar__controls {
display: flex;
flex-direction: column;
gap: var(--spacing-sm);
align-items: center;
}
.avatar__file-input {
display: none;
}
/* ============================================
STATS WINDOW
============================================ */
.stats-window {
width: 320px;
}
.stats__avatar {
width: 72px;
height: 72px;
object-fit: cover;
border-radius: var(--radius-full);
border: 2px solid var(--color-text);
align-self: center;
display: block;
margin: 0 auto var(--spacing-xs);
}
.stats__username {
font-size: var(--font-size-lg);
font-weight: 600;
text-align: center;
color: #000;
margin-bottom: var(--spacing-md);
}
.stats__section {
margin-bottom: var(--spacing-md);
}
.stats__section-title {
font-size: var(--font-size-sm);
font-weight: 700;
text-transform: uppercase;
letter-spacing: 0.08em;
color: var(--color-primary);
border-bottom: 1px solid var(--color-surface-light);
padding-bottom: var(--spacing-xs);
margin-bottom: var(--spacing-xs);
}
.stats__section-body {
display: flex;
flex-direction: column;
gap: 4px;
}
.stats__row {
display: flex;
justify-content: space-between;
font-size: var(--font-size-sm);
padding: 3px 0;
}
.stats__label {
color: #333;
}
.stats__value {
font-weight: 600;
color: #000;
}
.stats__loading {
font-size: var(--font-size-sm);
color: #333;
text-align: center;
padding: var(--spacing-sm) 0;
}
/* ============================================
UTILITIES
============================================ */
.hidden {
display: none !important;
}
.visually-hidden {
position: absolute;
width: 1px;
height: 1px;
padding: 0;
margin: -1px;
overflow: hidden;
clip: rect(0, 0, 0, 0);
border: 0;
}
.text-center {
text-align: center;
}
.flex-center {
display: flex;
align-items: center;
justify-content: center;
}
/* ============================================
FRIENDS WINDOW
============================================ */
.friends-window {
width: 400px;
height: 450px;
}
.friends__tabs {
display: flex;
gap: var(--spacing-xs);
margin-bottom: var(--spacing-sm);
}
.friends__tab {
flex: 1;
padding: var(--spacing-sm);
background: var(--color-surface-light);
border: 1px solid var(--color-surface-light);
color: var(--color-text);
cursor: pointer;
font-size: var(--font-size-sm);
transition: all var(--transition-fast);
}
.friends__tab:hover {
background: var(--color-surface-light);
}
.friends__tab--active {
background: var(--color-primary);
border-color: var(--color-primary);
}
.friends__content {
display: flex;
flex-direction: column;
flex: 1;
overflow: hidden;
}
.friends__search {
display: flex;
gap: var(--spacing-sm);
margin-bottom: var(--spacing-sm);
}
.friends__search .input {
flex: 1;
}
.friends__list {
flex: 1;
overflow-y: auto;
display: flex;
flex-direction: column;
gap: var(--spacing-sm);
}
.friends__item {
display: flex;
align-items: center;
gap: var(--spacing-sm);
padding: var(--spacing-sm);
background: var(--color-surface);
border-radius: var(--radius-md);
}
.friends__avatar {
width: 40px;
height: 40px;
border-radius: var(--radius-full);
object-fit: cover;
border: 2px solid var(--color-surface-light);
}
.friends__name {
flex: 1;
font-size: var(--font-size-md);
font-weight: 500;
}
.friends__actions {
display: flex;
gap: var(--spacing-xs);
}
.friends__actions .btn {
padding: var(--spacing-xs) var(--spacing-sm);
font-size: var(--font-size-sm);
}
.friends__empty {
text-align: center;
color: var(--color-text-muted);
padding: var(--spacing-lg);
}
+36 -54
View File
@@ -1,54 +1,36 @@
<!DOCTYPE html>
<head>
<link rel="stylesheet" href="./index.css" />
<script type="module" src="./index.js"></script>
</head>
<body>
<div id="header-1" class="container-1"
style="">
<div id="button-test" class="button-1 button-test multicolor" onclick="window.location.href = 'test/index.html';">TEST</div>
<div id="button-trans" class="button-trans multicolor">TRANSCENDENCE</div>
</div>
<img id="wiskas" style="margin: auto; display: block;" src="webcat/web_cat_img/wiskas-the-third.jpg">
<section style="display: flex;
justify-content: center;
width: 1000px;
margin: 0 auto;">
<p>I, am wiskas-the-third,
We are the cat company, we dont need to present our self for you already know
who we are, we created the internet, and we are still managing it now<br>
We at CAT are the admin, creator, and workers of the internet
Everytime a human goes to sleep, a cat start its shift, 1 billion pair of whiskers that are always here for you
Why? because we are philantropists, dont question it. Our goals are beyond your understanding
the internet was created by us, for us, and you should be glad we allow you to use it.
</p>
</section>
<section style="display: flex;">
<button style="margin-right: 50px;" class="button-1 multicolor" onclick="window.location.href = 'webcat/biblio.html';">
Latest News</button><br>
<button style="margin-left: 50px;" class="button-1 multicolor" onclick="window.location.href = 'webcat/staff/staff.html';">
meet the staff</button><br>
</section>
<footer>
<br><br><br>
<div class="footer_div" style="margin-top: 100px;">
<img class="ico_footer" src="webcat/web_cat_img/facebook_logo.png">
<img class="ico_footer" src="webcat/web_cat_img/insta_logo.png">
<img class="ico_footer" src="webcat/web_cat_img/twitter_logo.png">
</div>
<div class="footer_div" style="margin-bottom: 50px;">
<a href="https://www.facebook.com/">MIAOUBOOK</a>
<a href="https://www.instagram.com/">INSTAMIA</a>
<a href="https://twitter.com/">BLUE-SNACK</a>
</div>
<a href="./webcat/ml/mentions_legales.html">- LEGAL NOTICES -<br>(boring stuff, really, dont go look into this, i mean we are obligated to include it, but it will bore you, like, really)
<br>Dont do it! every seconds you spend in this next page, a kitten dies. so dont</a>
</footer>
</body>
</html>
<!doctype html>
<html lang="fr">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Transcendence</title>
<link rel="stylesheet" href="index.css" />
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
<link href="https://fonts.googleapis.com/css2?family=Cinzel+Decorative:wght@400;700&display=swap" rel="stylesheet" />
</head>
<body>
<h1 class="title">Transcendence</h1>
<nav class="menu" aria-label="Menu principal">
<button class="menu__item" data-action="login" aria-label="Login">Login</button>
<button class="menu__item" data-action="chat" aria-label="Global chat">Global chat</button>
<button class="menu__item" data-action="avatar" aria-label="Avatar">Avatar</button>
<button class="menu__item" data-action="friends" aria-label="Amis">Amis</button>
<button class="menu__item" data-action="test" aria-label="Test Page"
onclick="window.location.href='test.html'">Test Page</button>
</nav>
<nav class="game" aria-label="Game">
<button class="game__item" data-action="new_game" aria-label="Skkrrribl.io"
onclick="window.location.href='game.html'">Skkrrribl.io</button>
<button class="game__item" data-action="tetris" aria-label="Tetris"
onclick="window.location.href='tetris.html'">Tetris</button>
</nav>
<script type="module" src="app.js"></script>
</body>
</html>
-54
View File
@@ -1,54 +0,0 @@
import { updateElement } from "./test/tools.js";
import { colorizeText } from "./tools.js";
// //////////////////////////////////////////]
let div2 = document.createElement('div')
document.body.append(div2)
let button1 = document.createElement('button')
div2.append(button1)
button1.textContent = 'game-lobby'
button1.addEventListener('click', () => {
window.location.href = './game2/game.html';
})
let button2 = document.createElement('button')
div2.append(button2)
button2.textContent = 'tetris'
button2.addEventListener('click', () => {
window.location.href = './tetris/tetris.html';
})
let button4 = document.createElement('button')
div2.append(button4)
button4.textContent = 'test'
button4.addEventListener('click', () => {
window.location.href = './test/index.html';
})
let img = document.getElementById('wiskas');
img.before(div2)
// apply multicolor to .multicolor
colorizeText();
/* ///////////////////////////////////////////////////////// */
// make transcendence button move via: .button-trans
function updateButtonTranscendence(move) {
const btn = document.querySelector('.button-trans');
btn.addEventListener('mousemove', e => {
const rect = btn.getBoundingClientRect();
const x = ((e.clientX - rect.left) / rect.width - 0.5) * move;
const y = ((e.clientY - rect.top) / rect.height - 0.5) * move;
btn.style.backgroundPosition = `calc(50% + ${x}px) calc(50% + ${y}px)`;
});
btn.addEventListener('mouseleave', () => {
btn.style.backgroundPosition = 'center';
});
btn.addEventListener('click', () => {
window.location.href = './trans/index2.html';
});
}
/* ///////////////////////////////////////////////////////// */
updateButtonTranscendence(100);
@@ -1,6 +1,6 @@
import { Window } from '../core/windows.js';
import { API, STORAGE_KEYS, CSS } from '../core/config.js';
import { eventBus, Events } from '../core/events.js';
import { Window } from './windows.js';
import { API, STORAGE_KEYS, CSS } from './config.js';
import { eventBus, Events } from './events.js';
/**
* Login and registration window
@@ -83,8 +83,7 @@ export class LoginWindow extends Window {
bindEvents() {
this.loginBtn.addEventListener('click', () => this.handleLogin());
this.registerBtn.addEventListener('click', () => this.handleRegister());
this.githubBtn.addEventListener('click', () => {console.log(API.AUTH.GITHUB); this.handleGitHubLogin();});
this.githubBtn.addEventListener('click', () => this.handleGitHubLogin());
// Login with Enter
this.passwordInput.addEventListener('keypress', (e) => {
@@ -130,7 +129,6 @@ export class LoginWindow extends Window {
if (response.ok && data.token) {
localStorage.setItem(STORAGE_KEYS.AUTH_TOKEN, data.token);
this.showMessage('Login successful! Welcome.', 'success');
this.showNotification('Login successful', 'green');
// Emit login event
eventBus.emit(Events.USER_LOGGED_IN, { username, token: data.token });
@@ -140,7 +138,6 @@ export class LoginWindow extends Window {
} else {
const errorMsg = data?.message || 'Login failed';
this.showMessage(errorMsg, 'error');
this.showNotification(errorMsg, 'red');
}
} catch (error) {
console.error('Login error:', error);
@@ -173,12 +170,10 @@ export class LoginWindow extends Window {
if (response.ok) {
this.showMessage('Registration successful! You can now sign in.', 'success');
this.showNotification('Registration successful', 'green');
eventBus.emit(Events.USER_REGISTERED, { username });
} else {
const errorMsg = data?.message || 'Registration failed';
this.showMessage(errorMsg, 'error');
this.showNotification(errorMsg, 'red');
}
} catch (error) {
console.error('Registration error:', error);
@@ -195,8 +190,6 @@ export class LoginWindow extends Window {
const left = (screen.width - width) / 2;
const top = (screen.height - height) / 2;
console.log(API.AUTH.GITHUB);
const popup = window.open(
API.AUTH.GITHUB,
'githubOAuth',
@@ -207,7 +200,6 @@ export class LoginWindow extends Window {
if (event.data?.token) {
localStorage.setItem(STORAGE_KEYS.AUTH_TOKEN, event.data.token);
this.showMessage('GitHub login successful! Welcome.', 'success');
this.showNotification('GitHub login successful', 'green');
// Emit login event
eventBus.emit(Events.USER_LOGGED_IN, {
-188
View File
@@ -1,188 +0,0 @@
.test {/* =======================
🎨 COLORS & BACKGROUND
======================= */
color: red;
background-color: blue;
background-image: url(img.jpg);
background-size: cover;
background-position: center;
background-repeat: no-repeat;
opacity: 0.5;
/* =======================
📏 SIZE & SPACING
======================= */
width: 200px;
height: 100px;
min-width: 100px;
max-width: 500px;
padding: 10px;
margin: 20px;
box-sizing: border-box;
/* shorthand */
margin: 10px 20px; /* top/bottom left/right */
padding: 10px 20px 5px 0; /* top right bottom left */
/* =======================
📍 POSITIONING
======================= */
position: static;
position: relative;
position: absolute;
position: fixed;
position: sticky;
top: 10px;
left: 20px;
right: 0;
bottom: 0;
z-index: 10;
/* =======================
📦 DISPLAY & LAYOUT
======================= */
display: block;
display: inline;
display: inline-block;
display: none;
display: flex; /* children can be controled with: justify-content (horizontal) / align-items (vertical) */
display: grid;
/* =======================
🔧 FLEXBOX
======================= */
display: flex;
flex-direction: row; /* row | column */
justify-content: center; /* main axis */
align-items: center; /* cross axis */
gap: 10px;
/* common */
justify-content: space-between;
justify-content: space-around;
justify-content: space-evenly;
/* =======================
🧱 GRID
======================= */
display: grid;
grid-template-columns: 1fr 1fr 1fr;
grid-template-rows: auto;
gap: 10px;
/* =======================
🔤 TEXT & FONT
======================= */
font-size: 16px;
font-weight: bold;
font-family: Arial, sans-serif;
text-align: center;
text-decoration: underline;
text-transform: uppercase;
line-height: 1.5;
letter-spacing: 2px;
/* =======================
🟦 BORDER & OUTLINE
======================= */
border: 1px solid black;
border-width: 2px;
border-style: dashed;
border-color: red;
border-radius: 10px;
outline: 2px solid blue;
/* =======================
👁️ VISIBILITY
======================= */
display: none;
visibility: hidden;
overflow: hidden;
overflow: scroll;
overflow: auto;
/* =======================
🎬 TRANSITIONS & EFFECTS
======================= */
transition: all 0.3s ease;
transform: translateX(50px);
transform: rotate(45deg);
transform: scale(1.1);
}
/* hover example */
:hover {
transform: scale(1.1);
}
/* =======================
🧠 SELECTORS
======================= */
/* basic */
div {} /* tag */
.class {} /* class */
#id {} /* id */
* {} /* all elements */
/* grouping */
div, p, span {} /* multiple selectors */
/* combinators */
div p {} /* any descendant */
div > p {} /* direct child */
div + p {} /* next sibling */
div ~ p {} /* all following siblings */
/* attribute selectors */
input[type="text"] {}
a[href] {}
button[class*="btn"] {} /* contains */
button[class^="btn"] {} /* starts with */
button[class$="btn"] {} /* ends with */
/* pseudo-classes (state) */
button:hover {}
input:focus {}
a:active {}
a:visited {}
input:checked {}
:nth-child(2) {}
:nth-child(odd) {}
:nth-child(even) {}
:not(.active) {}
/* pseudo-elements (virtual parts) */
::before {}
::after {}
::placeholder {}
::first-letter {}
::first-line {}
/* combined examples */
button.primary:hover {}
div#main.content {}
ul li:first-child {}
input:focus::placeholder {}
/* universal + pseudo */
*::before {}
*::after {}
/* =======================
⚡ SHORTHANDS
======================= */
.test2 {
background: red url(img.jpg) no-repeat center/cover;
border: 2px solid black;
font: bold 16px Arial;
margin: 10px 20px;
padding: 5px 10px;
}
-123
View File
@@ -1,123 +0,0 @@
// SIZE
box.style.width = "200px";
box.style.height = "100px";
box.style.minWidth = "100px";
box.style.maxWidth = "500px";
{
display: "flex" // flex | inline-flex | block | inline | none
justifyContent: "flex-start" // flex-start | flex-end | center | space-between | space-around | space-evenly
alignItems: "stretch" // stretch | flex-start | flex-end | center | baseline
}
// POSITION
box.style.position = "absolute";
box.style.top = "50px";
box.style.left = "100px";
box.style.right = "20px";
box.style.bottom = "10px";
box.style.zIndex = "10";
// SPACING
box.style.margin = "10px";
box.style.padding = "20px";
box.style.marginTop = "10px";
box.style.paddingLeft = "5px";
// BACKGROUND & COLORS
box.style.background = "red";
box.style.backgroundColor = "blue";
box.style.color = "white";
// BORDER
box.style.border = "2px solid black";
box.style.borderRadius = "10px";
// TEXT
box.style.fontSize = "20px";
box.style.fontWeight = "bold";
box.style.textAlign = "center";
// DISPLAY & VISIBILITY
box.style.display = "block";
box.style.visibility = "visible";
box.style.opacity = "0.5";
// TRANSFORM
box.style.transform = "translateX(100px)";
box.style.transform = "translate(50px, 20px)";
box.style.transform = "scale(1.5)";
box.style.transform = "rotate(45deg)";
box.style.transform = "translateX(100px) scale(2)";
// ANIMATION & TRANSITION
box.style.transition = "all 0.3s ease";
box.style.animation = "move 2s linear";
// INTERACTION
box.style.cursor = "pointer";
box.style.pointerEvents = "none";
// /////////////////////////////////////////////////////>
// /////////////////////////////////////////////////////>
// CONTENT
el.textContent = "Hello"; // plain text
el.innerHTML = "<b>Hello</b>"; // HTML content
el.innerText = "Hello"; // like textContent but respects line breaks
// ATTRIBUTES
el.id = "myDiv"; // element ID
el.className = "box highlight"; // full class string
el.classList.add("active"); // add a class
el.classList.remove("hidden"); // remove a class
el.classList.toggle("open"); // toggle a class
el.title = "Tooltip text"; // title attribute
el.value = "42"; // input value
el.src = "image.png"; // img, video, audio src
el.href = "https://example.com"; // anchor href
el.alt = "alternative text"; // img alt
// DOM STRUCTURE
el.appendChild(child); // add child
el.append(child1, child2); // add multiple children
el.prepend(child); // add at start
el.remove(); // remove self
el.replaceWith(newEl); // replace element
el.cloneNode(true); // copy element (deep if true)
// DATA & CUSTOM
el.dataset.id = "123"; // data-id attribute
el.dataset.name = "box1"; // data-name attribute
// EVENTS
el.onclick = () => {}; // direct event assignment
el.onmouseover = () => {};
el.addEventListener("click", () => {}); // preferred
el.removeEventListener("click", handler);
// VISIBILITY & FOCUS
el.hidden = true; // hides element
el.focus(); // focus element
el.blur(); // remove focus
el.tabIndex = 0; // make element focusable
// DIMENSIONS & POSITION (read-only or get)
el.clientWidth;
el.clientHeight;
el.offsetWidth;
el.offsetHeight;
el.offsetTop;
el.offsetLeft;
el.scrollWidth;
el.scrollHeight;
el.scrollTop;
el.scrollLeft;
// OTHER
el.checked = true; // checkbox / radio
el.selected = true; // option element
el.disabled = true; // input/button
el.readOnly = true; // input/textarea
el.name = "username"; // input / form element
el.type = "text"; // input type
+133
View File
@@ -0,0 +1,133 @@
// ─────────────────────────────────────────────
// RENDU
// ─────────────────────────────────────────────
const CELL = 30;
const COLORS = ['#000500','#00ff41','#39ff14','#00e676','#76ff03','#b2ff59','#00ffaa','#ccff00','#2d5a2d'];
const ctxMain = document.getElementById('canvas-main').getContext('2d');
const ctxNext = document.getElementById('canvas-next').getContext('2d');
const ctxHold = document.getElementById('canvas-hold').getContext('2d');
const ctxOpponent = document.getElementById('canvas-opponent').getContext('2d');
function drawCell(ctx, x, y, colorIndex, size) {
const p = 1;
const color = COLORS[colorIndex];
ctx.fillStyle = color;
ctx.fillRect(x * size + p, y * size + p, size - p * 2, size - p * 2);
// Glow inner
ctx.shadowColor = color;
ctx.shadowBlur = 6;
ctx.fillStyle = color;
ctx.fillRect(x * size + p + 2, y * size + p + 2, size - p * 2 - 4, size - p * 2 - 4);
ctx.shadowBlur = 0;
// Highlight top/left
ctx.fillStyle = 'rgba(200,255,200,0.2)';
ctx.fillRect(x * size + p, y * size + p, size - p * 2, 2);
ctx.fillRect(x * size + p, y * size + p, 2, size - p * 2);
// Shadow bottom/right
ctx.fillStyle = 'rgba(0,0,0,0.5)';
ctx.fillRect(x * size + p, (y + 1) * size - p - 2, size - p * 2, 2);
ctx.fillRect((x + 1) * size - p - 2, y * size + p, 2, size - p * 2);
}
function clearCanvas(ctx, w, h) {
ctx.fillStyle = '#000500';
ctx.fillRect(0, 0, w, h);
}
function drawGridLines(ctx, cols, rows, size) {
ctx.strokeStyle = 'rgba(0,255,65,0.06)';
ctx.lineWidth = 1;
for (let x = 0; x <= cols; x++) {
ctx.beginPath(); ctx.moveTo(x * size, 0); ctx.lineTo(x * size, rows * size); ctx.stroke();
}
for (let y = 0; y <= rows; y++) {
ctx.beginPath(); ctx.moveTo(0, y * size); ctx.lineTo(cols * size, y * size); ctx.stroke();
}
}
function drawGhost(ctx, piece, grid) {
if (!piece) return;
const ghost = { x: piece.getPosition().x, y: piece.getPosition().y };
const shape = piece.getShape();
while (true) {
ghost.y++;
let valid = true;
for (let row = 0; row < shape.length && valid; row++)
for (let col = 0; col < shape[row].length && valid; col++)
if (shape[row][col] !== 0) {
const ny = ghost.y + row;
const nx = ghost.x + col;
if (ny < 0 || ny >= grid.length || nx < 0 || nx >= grid[ny].length || grid[ny][nx] !== 0) valid = false;
}
if (!valid) { ghost.y--; break; }
}
if (ghost.y === piece.getPosition().y) return;
ctx.strokeStyle = 'rgba(0,255,65,0.25)';
ctx.lineWidth = 1;
for (let row = 0; row < shape.length; row++)
for (let col = 0; col < shape[row].length; col++)
if (shape[row][col] !== 0)
ctx.strokeRect(
(ghost.x + col) * CELL + 2,
(ghost.y + row) * CELL + 2,
CELL - 4, CELL - 4
);
}
function drawMiniPiece(ctx, piece, canvasW, canvasH) {
clearCanvas(ctx, canvasW, canvasH);
if (!piece) return;
const shape = piece.getShape();
const color = piece.getColor();
const s = 20;
const offsetX = Math.floor((canvasW / s - shape[0].length) / 2);
const offsetY = Math.floor((canvasH / s - shape.length) / 2);
for (let row = 0; row < shape.length; row++)
for (let col = 0; col < shape[row].length; col++)
if (shape[row][col] !== 0)
drawCell(ctx, offsetX + col, offsetY + row, color, s);
}
function render() {
// Grille principale
clearCanvas(ctxMain, 300, 600);
drawGridLines(ctxMain, 10, 20, CELL);
for (let y = 0; y < game.grid.length; y++)
for (let x = 0; x < game.grid[y].length; x++)
if (game.grid[y][x] !== 0)
drawCell(ctxMain, x, y, game.grid[y][x], CELL);
// Ghost + pièce courante
if (game.currentPiece) {
drawGhost(ctxMain, game.currentPiece, game.grid);
const { x, y } = game.currentPiece.getPosition();
const shape = game.currentPiece.getShape();
const color = game.currentPiece.getColor();
for (let row = 0; row < shape.length; row++)
for (let col = 0; col < shape[row].length; col++)
if (shape[row][col] !== 0)
drawCell(ctxMain, x + col, y + row, color, CELL);
}
// Panneaux miniatures
drawMiniPiece(ctxNext, game.nextPiece, 100, 80);
drawMiniPiece(ctxHold, game.storedPiece, 100, 80);
// Score
document.getElementById('score-display').textContent = game.score;
}
function renderOpponent(opponentGrid) {
clearCanvas(ctxOpponent, 300, 600);
drawGridLines(ctxOpponent, 10, 20, CELL);
for (let y = 0; y < opponentGrid.length; y++)
for (let x = 0; x < opponentGrid[y].length; x++)
if (opponentGrid[y][x] !== 0)
drawCell(ctxOpponent, x, y, opponentGrid[y][x], CELL);
}
@@ -1,5 +1,5 @@
import { Window } from '../core/windows.js';
import { API, STORAGE_KEYS } from '../core/config.js';
import { Window } from './windows.js';
import { API, STORAGE_KEYS } from './config.js';
/**
* Stats window displays Scribble + Tetris stats for any user
+47
View File
@@ -0,0 +1,47 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Dynamic Hand-Drawn Shapes</title>
<link rel="stylesheet" href="doodle.css">
<script src="doodle.js" defer></script>
</head>
<body>
<div class="shape doodle-1 loop-color" id="shape1"></div>
<div class="shape doodle-2 loop-color" id="shape2"></div>
<div class="shape doodle-3 loop-color" id="shape3"></div>
<div class="shape doodle-4 loop-color" id="shape4"></div>
<div class="shape doodle-5 loop-color" id="shape5"></div>
<div class="shape doodle-6 loop-color" id="shape6"></div>
<div class="shape doodle-7 loop-color" id="shape7"></div>
<div class="shape doodle-8 loop-color" id="shape8"></div>
<div class="shape doodle-9 loop-color" id="shape9"></div>
<div class="shape doodle-10 loop-color" id="shape10"></div>
<div class="shape doodle-11 loop-color" id="shape11"></div>
<div class="shape doodle-12 loop-color" id="shape12"></div>
<div class="shape doodle-13 loop-color" id="shape13"></div>
<div class="shape doodle-14 loop-color" id="shape14"></div>
<div class="shape doodle-15 loop-color" id="shape15"></div>
<div class="shape doodle-16 loop-color" id="shape16"></div>
<div class="shape doodle-17 loop-color" id="shape17"></div>
<div class="shape doodle-18 loop-color" id="shape18"></div>
<div class="shape doodle-19 loop-color" id="shape19"></div>
<div class="shape doodle-20 loop-color" id="shape20"></div>
<div class="shape doodle-21 loop-color" id="shape21"></div>
<div class="shape doodle-22 loop-color" id="shape22"></div>
<div class="shape doodle-23 loop-color" id="shape23"></div>
<div class="shape doodle-24 loop-color" id="shape24"></div>
<div class="shape doodle-25 loop-color" id="shape25"></div>
<div class="shape doodle-26 loop-color" id="shape26"></div>
<div class="shape doodle-27 loop-color" id="shape27"></div>
<div class="shape doodle-28 loop-color" id="shape28"></div>
<div class="shape doodle-29 loop-color" id="shape29"></div>
<div class="shape doodle-30 loop-color" id="shape30"></div>
<div class="shape doodle-31 loop-color" id="shape31"></div>
<div class="shape doodle-32 loop-color" id="shape32"></div>
<div class="shape doodle-33 loop-color" id="shape33"></div>
<div class="shape doodle-34 loop-color" id="shape34"></div>
<div class="shape doodle-35 loop-color" id="shape35"></div>
</body>
</html>
@@ -1,55 +0,0 @@
import fetch from 'node-fetch';
import express, { response } from 'express';
import cors from 'cors';
const app = express();
const PORT = 3000//process.env.PORT || 3000;
app.use(express.json());
app.use(cors());
let token;
async function set_token()
{
fetch("https://api.intra.42.fr/oauth/token", {
method: "POST",
body: "grant_type=client_credentials&client_id=u-s4t2ud-c226cd35cd1ac08a4c6668deee1c64d7d67a13a766aee672acafd4a1522d483c&client_secret=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",
headers: {
"User-Agent": "agallon",
'Content-Type': 'application/x-www-form-urlencoded',}
})
.then(response => {
return response.json();
})
.then(data => {
token = data;
setTimeout(set_token, token.expires_in);
})
.catch(error => {
console.error('Error fetching token:', error);
});
}
set_token();
app.get('/proxy/profile/:login', async (req, res) => {
const { login } = req.params;
const profileURL = `https://api.intra.42.fr/v2/users/${login}`;
try {
const response = await fetch(profileURL, {
headers: {
"Authorization": `Bearer ${token.access_token}`}});
console.log(`response.status = ${response.status}`);
if (response.status !== 200) {
throw new Error('User not found');
}
const data = await response.json();
res.status(200).json(data);
} catch (error) {
console.error('Error fetching profile:', error);
res.status(500).json({ error: 'Failed to fetch profile' });
}
});
app.listen(PORT, () => {
console.log(`Proxy server running on port ${PORT}`);
});
@@ -1,26 +0,0 @@
import {checkIfLoggedIn} from './tools.js';
export class Header {
constructor() {
this.obj = document.createElement('div');
Object.assign(this.obj.style, {
});
let play = document.createElement('span');
let title = document.createElement('span');
let login = document.createElement('span');
play.textContent = "PLAY";
if (checkIfLoggedIn())
title.textContent = "Welcome back you!";
else
title.textContent = "Welcome to CAT !";
this.obj.append(play);
this.obj.append(title);
this.obj.append(login);
}
}
@@ -1,44 +0,0 @@
export class Popup {
constructor(msg, parent = document.body) {
this.msg = msg;
this.parent = parent;
this.obj = document.createElement('span');
this.obj.className = "popup";
this.obj.textContent = "";
this.obj.style.opacity = "0";
this.run();
}
async create() {
this.parent.appendChild(this.obj);
this.obj.style.transition = "opacity 0.5s ease";
requestAnimationFrame(() => {
this.obj.style.opacity = "1";
});
await new Promise(r => setTimeout(r, 500));
}
async write(speed = 50) {
for (let i = 0; i < this.msg.length; i++) {
this.obj.textContent += this.msg[i];
await new Promise(r => setTimeout(r, speed));
}
}
async remove() {
await new Promise(r => setTimeout(r, 2000));
this.obj.style.transition = "opacity 0.3s ease";
this.obj.style.opacity = "0";
await new Promise(r => setTimeout(r, 300));
if (this.obj.parentNode) {
this.obj.parentNode.removeChild(this.obj);
}
}
async run() {
await this.create();
await this.write();
await this.remove();
}
}
@@ -1,9 +0,0 @@
import { STORAGE_KEYS } from '../../core/config.js';
export function checkIfLoggedIn() {
const token = localStorage.getItem(STORAGE_KEYS.AUTH_TOKEN);
if (token) {
return true;
}
return false;
}
@@ -1,43 +0,0 @@
/* ////////////////////////////////////////// */
.box {
background: #142d4a;
height: 200px;
aspect-ratio: 1/1;
border-radius: 10px;
position: relative;
display: flex;
justify-content: center;
align-items: center;
}
@property --deg {
syntax: '<angle>';
inherits: true;
initial-value: 0deg;
}
.box::before,
.box::after {
content: "";
position: absolute;
height: 100%;
width: 100%;
background: conic-gradient(
from var(--deg) at center,
#00c3ff,
#4d0199,
#6300c6,
#009dcd
);
border-radius: inherit;
z-index: -2;
padding: 2px;
animation: autoRotate 2s linear infinite;
}
.box::after {
filter: blur(10px);
}
@keyframes autoRotate {
to{ --deg: 360deg; }
}
@@ -1,17 +0,0 @@
<!DOCTYPE html>
<head>
<link rel="stylesheet" href="../game2/game.css" />
<link rel="stylesheet" href="./style.css" />
<script type="module" src="./script.js"></script>
</head>
<body style="background-color: black; display: flex; justify-content: center; align-items: center;">
<!--
<div class="container">
<div class="item item-1">Item 1</div>
<div class="item item-2">Item 2</div>
<div class="item item-3">Item 3</div>
</div> -->
<div></div>
<div class="box"></div>
</body>
</html>
@@ -1,17 +0,0 @@
// import { LoginSidebar } from "./loginSidebar.js";
import { Sidebar } from "./sidebar.js";
import { updateElement } from "./tools.js";
let b = updateElement({
classList: ['container2'],
additionalStyles: {
display: 'flex',
justifyContent: 'flex-end',
alignItems: 'center'
}
});
new Sidebar();
// new LoginSidebar();
// new Sidebar();
@@ -1,93 +0,0 @@
import { updateElement } from "./tools.js";
import { windowRegistry } from '../core/windows.js';
import { LoginWindow } from '../windows/login.js';
import { LogoutWindow } from '../windows/logout.js';
import { GlobalChat } from '../windows/global_chat.js';
import { AvatarWindow } from '../windows/avatar.js';
import { FriendsWindow } from '../windows/friends.js';
import { GameRoomWindow } from '../windows/game_room.js';
import { StatsWindow } from '../windows/stats.js';
export class Sidebar {
/* CONSTURCTOR */
constructor(parent = document.body) {
this.parent = parent;
this.stateopen = 'closed';
// this.state = this.checkIfLoggedIn() ? "loggedOut" : "loggedIn";
this.obj = updateElement({
parent: parent,
id: `login-wrapper`,
classList: [ 'login-wrapper' ],
})
this.createAllButtons();
this.handleClickOutside = (event) => {
if (this.stateopen === 'open' && !this.obj.contains(event.target)) {
this.toggle();
}
};
}
/* toogle menu open / closed */
toggle() {
this.stateopen = (this.stateopen === 'open') ? 'closed' : 'open';
console.log(this.stateopen);
if (this.stateopen === 'open') {
this.main_button.style.display = 'none';
this.menu_buttons.forEach(b => b.style.display = 'block');
// ensure only ONE listener exists
document.removeEventListener('click', this.handleClickOutside);
document.addEventListener('click', this.handleClickOutside);
}
else {
this.menu_buttons.forEach(b => b.style.display = 'none');
this.main_button.style.display = 'block';
document.removeEventListener('click', this.handleClickOutside);
}
}
/* create all element, append to div */
createAllButtons() {
// not-logged closed button
this.main_button = updateElement({
id: `button-main`,
parent: this.obj,
textContent: 'LOGIN',
classList: [ 'login-button' ],
})
this.obj.append(this.main_button);
this.main_button.addEventListener('click', (e) => {
e.stopPropagation();
this.toggle();
})
// menu buttons
const items = ['friends', 'chat', 'rooms', 'settings', 'log','logout'];
this.menu_buttons = [];
items.forEach(name => {
this[name] = updateElement({
id: `button-${name}`,
parent: this.obj,
textContent: name,
classList: ['login-button'],
additionalStyles: { display: 'none'}
})
this.menu_buttons.push(this[name]);
this.obj.append(this[name]);
})
this.loginWindow = new LoginWindow();
this.obj.append(this.loginWindow.form);
this.loginWindow.form.style.display = 'none';
this['log'].addEventListener('click', () => {
this.menu_buttons.forEach(b => b.style.display = 'none');
this.loginWindow.form.style.display = 'block';
})
// menu elements
}
}
@@ -1,138 +0,0 @@
/* BASE STYLES */
:root {
--clr-dark: #0f172a;
--clr-light: #f1f5f9;
--clr-accent: #e11d48;
}
*,
*::before,
*::after {
box-sizing: border-box;
}
body {
margin: 0;
padding: 0;
line-height: 1.6; /* inherited */
word-spacing: 1.4px; /* inherited */
font-family: "Roboto", sans-serif; /* inherited */
color: var(--clr-dark); /* inherited */
background-color: var(--clr-light);
/* display: flex; */
/* justify-content: center; */
/* align-items: center; */
height: 100vh;
position: relative;
}
.container {
width: 80%;
height: 700px;
margin: 0 auto;
border: 10px solid var(--clr-dark);
}
.item {
width: 150px;
height: 150px;
background-color: #fb7185;
padding: 1em;
font-weight: 700;
color: var(--clr-light);
text-align: center;
border: 10px solid var(--clr-accent);
border-radius: 10px;
margin-left: -50px
}
/* END OF BASE STYLES */
.item-1 {
font-size: 1.5rem;
}
.container {
display: flex;
}
.container2 {
margin: 0 auto;
border: 10px solid var(--clr-dark);
}
/*//////////////////////////////////////////////////////////*/
.button {
padding: 10px 18px;
font-size: 14px;
font-family: inherit;
color: white;
background-color: #3b82f6; /* blue */
border: none;
border-radius: 8px;
cursor: pointer;
transition: all 0.2s ease;
}
.button:hover {
background-color: #2563eb;
transform: translateY(-1px);
}
.button:active {
transform: translateY(1px);
background-color: #1d4ed8;
}
.button:focus {
outline: none;
box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.4);
}
/*//////////////////////////////////////////////////////////*/
.login-wrapper {
display: flex;
flex-direction: column;
gap: 7px;
background-color: #3b82f6; /* blue */
padding-right: 75px;
padding-bottom: 25px;
padding-top: 25px;
position: fixed;
top: 0;
right: 0;
}
.loggin-button {
position: relative;
display: inline-block;
border: 5px solid blue;
height: 35px;
min-width: 50px;
}
/*//////////////////////////////////////////////////////////*/
/* LOGIN */
.login-button {
width: 150px;
height: 150px;
background-color: #fb7185;
padding: 1em;
font-weight: 700;
color: var(--clr-light);
text-align: center;
border: 10px solid var(--clr-accent);
border-radius: 10px;
margin-left: -50px
}
.login-element {
}

Some files were not shown because too many files have changed in this diff Show More