mirror of
https://github.com/AudebertAdrien/ft_transcendence.git
synced 2026-02-04 11:40:25 +01:00
Merge branch 'main' of github.com:AudebertAdrien/ft_transcendence into trash
This commit is contained in:
commit
58e3602ea8
6
.env
6
.env
@ -1,7 +1,7 @@
|
|||||||
# Django settings
|
# Django settings
|
||||||
SECRET_KEY="FollowTheWhiteRabbit"
|
SECRET_KEY="FollowTheWhiteRabbit"
|
||||||
DEBUG=True
|
DEBUG=True
|
||||||
DJANGO_ALLOWED_HOSTS=localhost 127.0.0.1 [::1]
|
DJANGO_ALLOWED_HOSTS=['*']
|
||||||
|
|
||||||
# PostgreSQL settings
|
# PostgreSQL settings
|
||||||
POSTGRES_DB=players_db
|
POSTGRES_DB=players_db
|
||||||
@ -11,5 +11,5 @@ POSTGRES_PASSWORD=qwerty
|
|||||||
DB_HOST=db
|
DB_HOST=db
|
||||||
DB_PORT=5432
|
DB_PORT=5432
|
||||||
|
|
||||||
PROJECT_PATH=${PWD}/pong
|
PROJECT_PATH=/home/mchiboub/42cursus/transcendence/pong
|
||||||
POSTGRES_DATA_PATH=${PWD}/data/db
|
POSTGRES_DATA_PATH=/home/mchiboub/42cursus/transcendence/data/db
|
||||||
2
.gitignore
vendored
2
.gitignore
vendored
@ -1,3 +1,5 @@
|
|||||||
venv/
|
venv/
|
||||||
__pycache__/
|
__pycache__/
|
||||||
data/
|
data/
|
||||||
|
.env
|
||||||
|
makefile
|
||||||
2
makefile
2
makefile
@ -28,8 +28,6 @@ destroy:
|
|||||||
logs:
|
logs:
|
||||||
$(COMPOSE) logs -f $(CONTAINER)
|
$(COMPOSE) logs -f $(CONTAINER)
|
||||||
|
|
||||||
re: destroy up
|
|
||||||
|
|
||||||
ps:
|
ps:
|
||||||
$(COMPOSE) ps
|
$(COMPOSE) ps
|
||||||
|
|
||||||
|
|||||||
@ -126,9 +126,13 @@ class Game:
|
|||||||
# Check for scoring
|
# Check for scoring
|
||||||
if self.game_state['ball_position']['x'] <= 10:
|
if self.game_state['ball_position']['x'] <= 10:
|
||||||
self.game_state['player2_score'] += 1
|
self.game_state['player2_score'] += 1
|
||||||
|
if self.game_state['player2_score'] >= 5:
|
||||||
|
self.end_game()
|
||||||
self.reset_ball()
|
self.reset_ball()
|
||||||
elif self.game_state['ball_position']['x'] >= 790:
|
elif self.game_state['ball_position']['x'] >= 790:
|
||||||
self.game_state['player1_score'] += 1
|
self.game_state['player1_score'] += 1
|
||||||
|
if self.game_state['player1_score'] >= 5:
|
||||||
|
self.end_game()
|
||||||
self.reset_ball()
|
self.reset_ball()
|
||||||
|
|
||||||
def reset_ball(self):
|
def reset_ball(self):
|
||||||
|
|||||||
@ -40,7 +40,7 @@ class MatchMaker:
|
|||||||
await asyncio.sleep(1)
|
await asyncio.sleep(1)
|
||||||
self.timer += 1
|
self.timer += 1
|
||||||
# Waiting for more than 30s -> BOT game
|
# Waiting for more than 30s -> BOT game
|
||||||
if self.timer >= 3 and self.waiting_players:
|
if self.timer >= 30 and self.waiting_players:
|
||||||
player1 = self.waiting_players.pop(0)
|
player1 = self.waiting_players.pop(0)
|
||||||
print(f"*** MATCH FOUND: {player1.user.username} vs BOT")
|
print(f"*** MATCH FOUND: {player1.user.username} vs BOT")
|
||||||
self.botgame = True
|
self.botgame = True
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
# Generated by Django 5.0.7 on 2024-07-31 15:16
|
# Generated by Django 5.0.7 on 2024-07-31 16:01
|
||||||
|
|
||||||
import django.db.models.deletion
|
import django.db.models.deletion
|
||||||
from django.db import migrations, models
|
from django.db import migrations, models
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
# Generated by Django 5.0.7 on 2024-07-31 16:58
|
# Generated by Django 5.0.7 on 2024-07-31 16:04
|
||||||
|
|
||||||
import django.db.models.deletion
|
import django.db.models.deletion
|
||||||
from django.db import migrations, models
|
from django.db import migrations, models
|
||||||
|
|||||||
@ -20,6 +20,8 @@ document.addEventListener('DOMContentLoaded', () => {
|
|||||||
const matchList = document.getElementById('match-list');
|
const matchList = document.getElementById('match-list');
|
||||||
const dropdownMenu = document.getElementById('dropdown-menu');
|
const dropdownMenu = document.getElementById('dropdown-menu');
|
||||||
|
|
||||||
|
const pongElements = document.getElementById('pong-elements');
|
||||||
|
const logo = document.querySelector('.logo');
|
||||||
|
|
||||||
let socket;
|
let socket;
|
||||||
let token;
|
let token;
|
||||||
@ -38,7 +40,6 @@ document.addEventListener('DOMContentLoaded', () => {
|
|||||||
registerButton.addEventListener('click', handleRegister);
|
registerButton.addEventListener('click', handleRegister);
|
||||||
loginButton.addEventListener('click', handleLogin);
|
loginButton.addEventListener('click', handleLogin);
|
||||||
|
|
||||||
|
|
||||||
async function handleCheckNickname() {
|
async function handleCheckNickname() {
|
||||||
const nickname = nicknameInput.value.trim();
|
const nickname = nicknameInput.value.trim();
|
||||||
if (nickname) {
|
if (nickname) {
|
||||||
@ -101,10 +102,11 @@ document.addEventListener('DOMContentLoaded', () => {
|
|||||||
try {
|
try {
|
||||||
const result = await registerUser(nickname, password);
|
const result = await registerUser(nickname, password);
|
||||||
if (result) {
|
if (result) {
|
||||||
//await createPlayer(nickname);
|
|
||||||
registerForm.style.display = 'none';
|
registerForm.style.display = 'none';
|
||||||
gameContainer.style.display = 'flex';
|
gameContainer.style.display = 'flex';
|
||||||
formBlock.style.display = 'none';
|
formBlock.style.display = 'none';
|
||||||
|
logo.style.display = 'none';
|
||||||
|
pongElements.style.display = 'none';
|
||||||
startWebSocketConnection(token);
|
startWebSocketConnection(token);
|
||||||
} else {
|
} else {
|
||||||
alert('Registration failed. Please try again.');
|
alert('Registration failed. Please try again.');
|
||||||
@ -141,6 +143,8 @@ document.addEventListener('DOMContentLoaded', () => {
|
|||||||
loginForm.style.display = 'none';
|
loginForm.style.display = 'none';
|
||||||
gameContainer.style.display = 'flex';
|
gameContainer.style.display = 'flex';
|
||||||
formBlock.style.display = 'none';
|
formBlock.style.display = 'none';
|
||||||
|
logo.style.display = 'none';
|
||||||
|
pongElements.style.display = 'none';
|
||||||
startWebSocketConnection(token);
|
startWebSocketConnection(token);
|
||||||
} else {
|
} else {
|
||||||
alert('Authentication failed. Please try again.');
|
alert('Authentication failed. Please try again.');
|
||||||
|
|||||||
@ -16,7 +16,7 @@
|
|||||||
<div class="background">
|
<div class="background">
|
||||||
<div class="stars" id="stars"></div>
|
<div class="stars" id="stars"></div>
|
||||||
</div>
|
</div>
|
||||||
<div class="pong-elements">
|
<div id="pong-elements" style="display: flex;">
|
||||||
<div class="paddle paddle-left"></div>
|
<div class="paddle paddle-left"></div>
|
||||||
<div class="paddle paddle-right"></div>
|
<div class="paddle paddle-right"></div>
|
||||||
<div class="ball_anim"></div>
|
<div class="ball_anim"></div>
|
||||||
@ -169,10 +169,6 @@
|
|||||||
star.style.animationDuration = `${Math.random() * 2 + 1}s`;
|
star.style.animationDuration = `${Math.random() * 2 + 1}s`;
|
||||||
starsContainer.appendChild(star);
|
starsContainer.appendChild(star);
|
||||||
}
|
}
|
||||||
|
|
||||||
setInterval(createTrail, 100);
|
|
||||||
|
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
|
|||||||
@ -124,16 +124,22 @@ button:hover {
|
|||||||
|
|
||||||
#player1-pad {
|
#player1-pad {
|
||||||
left: 10px;
|
left: 10px;
|
||||||
|
background-color: #00ffff;
|
||||||
|
border-radius: 10px;
|
||||||
|
box-shadow: 0 0 15px #00ffff;
|
||||||
}
|
}
|
||||||
|
|
||||||
#player2-pad {
|
#player2-pad {
|
||||||
right: 10px;
|
right: 10px;
|
||||||
|
background-color: #00ffff;
|
||||||
|
border-radius: 10px;
|
||||||
|
box-shadow: 0 0 15px #00ffff;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ball {
|
#ball {
|
||||||
width: 20px;
|
width: 20px;
|
||||||
height: 20px;
|
height: 20px;
|
||||||
background-color: #ffffff;
|
background-color: #00ffff;
|
||||||
border-radius: 50%;
|
border-radius: 50%;
|
||||||
position: absolute;
|
position: absolute;
|
||||||
}
|
}
|
||||||
@ -142,12 +148,14 @@ button:hover {
|
|||||||
position: absolute;
|
position: absolute;
|
||||||
top: 20px;
|
top: 20px;
|
||||||
left: 20px;
|
left: 20px;
|
||||||
font-size: 3rem;
|
|
||||||
color: #00ffff;
|
|
||||||
text-shadow: 0 0 15px #00ffff;
|
|
||||||
z-index: 20;
|
z-index: 20;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.logo img {
|
||||||
|
max-width: 100%;
|
||||||
|
height: auto;
|
||||||
|
}
|
||||||
|
|
||||||
.stars {
|
.stars {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user