some fixes

This commit is contained in:
CHIBOUB Chakib 2024-08-05 17:39:37 +02:00
parent 73d095ddc4
commit 4a504545dd
7 changed files with 19 additions and 13 deletions

4
.env
View File

@ -11,5 +11,5 @@ POSTGRES_PASSWORD=qwerty
DB_HOST=db
DB_PORT=5432
PROJECT_PATH=${PWD}/pong
POSTGRES_DATA_PATH=${PWD}/data/db
PROJECT_PATH=/home/mchiboub/42cursus/transcendence/pong
POSTGRES_DATA_PATH=/home/mchiboub/42cursus/transcendence/data/db

View File

@ -28,8 +28,6 @@ destroy:
logs:
$(COMPOSE) logs -f $(CONTAINER)
re: destroy up
ps:
$(COMPOSE) ps

View File

@ -126,9 +126,13 @@ class Game:
# Check for scoring
if self.game_state['ball_position']['x'] <= 10:
self.game_state['player2_score'] += 1
if self.game_state['player2_score'] >= 5:
self.end_game()
self.reset_ball()
elif self.game_state['ball_position']['x'] >= 790:
self.game_state['player1_score'] += 1
if self.game_state['player1_score'] >= 5:
self.end_game()
self.reset_ball()
def reset_ball(self):

View File

@ -40,7 +40,7 @@ class MatchMaker:
await asyncio.sleep(1)
self.timer += 1
# 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)
print(f"*** MATCH FOUND: {player1.user.username} vs BOT")
self.botgame = True

View File

@ -11,7 +11,8 @@ document.addEventListener('DOMContentLoaded', () => {
const loginForm = document.getElementById('login-form');
const registerForm = document.getElementById('register-form');
const formBlock = document.getElementById('block-form');
const pongElements = document.getElementById('pong-elements');
const logo = document.querySelector('.logo');
let socket;
let token;
@ -95,6 +96,8 @@ document.addEventListener('DOMContentLoaded', () => {
registerForm.style.display = 'none';
gameContainer.style.display = 'flex';
formBlock.style.display = 'none';
logo.style.display = 'none';
pongElements.style.display = 'none';
startWebSocketConnection(token);
} else {
alert('Registration failed. Please try again.');
@ -131,6 +134,8 @@ document.addEventListener('DOMContentLoaded', () => {
loginForm.style.display = 'none';
gameContainer.style.display = 'flex';
formBlock.style.display = 'none';
logo.style.display = 'none';
pongElements.style.display = 'none';
startWebSocketConnection(token);
} else {
alert('Authentication failed. Please try again.');

View File

@ -10,14 +10,13 @@
<div class="logo">
<img src="{% static 'logo-42-perpignan.png' %}" alt="Logo">
</div>
</head>
<body>
<div class="background">
<div class="stars" id="stars"></div>
</div>
<div class="pong-elements">
<div id="pong-elements" style="display: flex;">
<div class="paddle paddle-left"></div>
<div class="paddle paddle-right"></div>
<div class="ball_anim"></div>
@ -71,8 +70,6 @@
star.style.animationDuration = `${Math.random() * 2 + 1}s`;
starsContainer.appendChild(star);
}
setInterval(createTrail, 100);
</script>
</body>

View File

@ -141,12 +141,14 @@ button:hover {
position: absolute;
top: 20px;
left: 20px;
font-size: 3rem;
color: #00ffff;
text-shadow: 0 0 15px #00ffff;
z-index: 20;
}
.logo img {
max-width: 100%;
height: auto;
}
.stars {
position: absolute;
width: 100%;