Petits ajustements

This commit is contained in:
François Pelletier 2024-09-07 18:19:15 -04:00
parent f49310ff5f
commit 72f1a72b7c
3 changed files with 46 additions and 5 deletions

View file

@ -1,5 +1,6 @@
@()
@main("Welcome to Play") {
<h1>Welcome to Play</h1>
<h1>Déconstruit - Le jeu !</h1>
<p><a href="/game">Jouer</a></p>
}

30
embed/embed.html Normal file
View file

@ -0,0 +1,30 @@
<style>
.responsive-iframe-container {
position: relative;
overflow: hidden;
width: 100%;
padding-top: 125%; /* Aspect ratio: 540:675 (height/width = 1.25) */
}
.responsive-iframe-container iframe {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
border: 0;
}
</style>
<div class="responsive-iframe-container">
<iframe src="https://deconstruit-breakout.coolify.jevalide.ca/game" style="overflow: hidden;"></iframe>
</div>
<script>
window.addEventListener('message', function(e) {
if (e.data.type === 'setHeight') {
var container = document.querySelector('.responsive-iframe-container');
var aspectRatio = e.data.height / e.data.width;
container.style.paddingTop = (aspectRatio * 100) + '%';
}
}, false);
</script>

View file

@ -17,13 +17,18 @@ let paddle = { x: 175, y: 510, width: 75, height: 15 };
let ball = { x: 200, y: 370, dx: 4, dy: -4, radius: 8 };
const floorY = 525; // Define the floor position
let isPaused = false;
let isPaused = true;
function togglePause() {
isPaused = !isPaused;
if (!isPaused) {
requestAnimationFrame(update);
}
updatePauseButton(); // We'll add this function
}
function updatePauseButton() {
pauseButton.textContent = isPaused ? 'Démarrer' : 'Pause';
}
function drawBricks() {
@ -79,7 +84,11 @@ function drawPauseScreen() {
ctx.fillRect(0, 0, canvas.width, canvas.height);
ctx.fillStyle = 'white';
ctx.font = '30px Arial';
ctx.fillText('PAUSED', canvas.width / 2 - 50, canvas.height / 2);
if (bricks.length === 0) {
ctx.fillText('PAUSE', canvas.width / 2 - 50, canvas.height / 2);
} else {
ctx.fillText("Clique 'Démarrer' pour jouer", canvas.width / 2 - 175, canvas.height / 2);
}
}
function update() {
@ -169,7 +178,7 @@ document.addEventListener('keydown', function(e) {
// Create pause button
const pauseButton = document.createElement('button');
pauseButton.textContent = 'Pause';
pauseButton.textContent = 'Démarrer'; // Changed from 'Pause' to 'Démarrer'
pauseButton.style.position = 'absolute';
pauseButton.style.top = '10px';
pauseButton.style.left = '10px';
@ -209,7 +218,8 @@ fetch(`/bricks?file=${randomFile}`)
.then(data => {
bricks = data;
updateThemeHeader(theme);
update();
drawPauseScreen(); // Draw the pause screen instead of starting the game
updatePauseButton();
});
document.addEventListener('mousemove', movePaddle, true);