APmanageur Wi-Fi V1.0
This commit is contained in:
1 parent
f78e380236
commit
2b33e31589
4 files changed
+423
-119
No files matched your search
+87
-20
@@ -267,7 +267,7 @@
|
||||
|
||||
<div class="game-card">
|
||||
<div class="header-bar">
|
||||
<div>🦖 <strong>Chrome T-Rex Runner</strong></div>
|
||||
<div>🦖 <strong id="dinoTitleText">Chrome T-Rex Runner</strong></div>
|
||||
<div class="scores">
|
||||
<span class="hi">HI <span id="hiScore">00000</span></span>
|
||||
<span id="currentScore">00000</span>
|
||||
@@ -277,20 +277,20 @@
|
||||
<div class="canvas-wrap" id="canvasWrap">
|
||||
<canvas id="dinoCanvas" width="640" height="220"></canvas>
|
||||
<div id="gameOverlay" class="overlay-message" style="display:none">
|
||||
<h2>G A M E O V E R</h2>
|
||||
<button class="restart-btn" onclick="resetGame()">🔄 REJOUER (Espace)</button>
|
||||
<h2 id="dinoGameOverText">G A M E O V E R</h2>
|
||||
<button id="dinoRestartBtn" class="restart-btn" onclick="resetGame()">🔄 REJOUER (Espace)</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="controls-hint">
|
||||
<div><kbd>Espace</kbd> ou <kbd>⬆️</kbd> : Sauter</div>
|
||||
<div><kbd>⬇️</kbd> : Se baisser / descente rapide</div>
|
||||
<div>Toucher l'écran pour sauter</div>
|
||||
<div class="controls-hint" id="dinoControlsHint">
|
||||
<div id="dinoHintJump"><kbd>Espace</kbd> ou <kbd>⬆️</kbd> : Sauter</div>
|
||||
<div id="dinoHintDuck"><kbd>⬇️</kbd> : Se baisser / descente rapide</div>
|
||||
<div id="dinoHintTouch">Toucher l'écran pour sauter</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
// Theme Management
|
||||
// Theme & i18n Management
|
||||
function setTheme(theme, macosMode) {
|
||||
if (!theme) theme = 'dark';
|
||||
document.documentElement.dataset.theme = theme;
|
||||
@@ -304,10 +304,51 @@
|
||||
const urlParams = new URLSearchParams(window.location.search);
|
||||
setTheme(urlParams.get('theme') || 'dark', urlParams.get('macosMode'));
|
||||
|
||||
// Dictionnaire i18n
|
||||
const I18N_DINO = {
|
||||
fr: {
|
||||
title: "Chrome T-Rex Runner",
|
||||
game_over: "G A M E O V E R",
|
||||
restart_btn: "🔄 REJOUER (Espace)",
|
||||
hint_jump: "<kbd>Espace</kbd> ou <kbd>⬆️</kbd> : Sauter",
|
||||
hint_duck: "<kbd>⬇️</kbd> : Se baisser / descente rapide",
|
||||
hint_touch: "Toucher l'écran pour sauter"
|
||||
},
|
||||
en: {
|
||||
title: "Chrome T-Rex Runner",
|
||||
game_over: "G A M E O V E R",
|
||||
restart_btn: "🔄 REPLAY (Space)",
|
||||
hint_jump: "<kbd>Space</kbd> or <kbd>⬆️</kbd>: Jump",
|
||||
hint_duck: "<kbd>⬇️</kbd>: Duck / Fast drop",
|
||||
hint_touch: "Tap screen to jump"
|
||||
}
|
||||
};
|
||||
|
||||
function applyDinoLang(lang) {
|
||||
const l = (lang && (lang.startsWith('en') ? 'en' : 'fr')) || 'fr';
|
||||
const dict = I18N_DINO[l] || I18N_DINO.fr;
|
||||
const tEl = document.getElementById('dinoTitleText');
|
||||
const goEl = document.getElementById('dinoGameOverText');
|
||||
const rbEl = document.getElementById('dinoRestartBtn');
|
||||
const hjEl = document.getElementById('dinoHintJump');
|
||||
const hdEl = document.getElementById('dinoHintDuck');
|
||||
const htEl = document.getElementById('dinoHintTouch');
|
||||
if (tEl) tEl.textContent = dict.title;
|
||||
if (goEl) goEl.innerHTML = dict.game_over;
|
||||
if (rbEl) rbEl.textContent = dict.restart_btn;
|
||||
if (hjEl) hjEl.innerHTML = dict.hint_jump;
|
||||
if (hdEl) hdEl.innerHTML = dict.hint_duck;
|
||||
if (htEl) htEl.textContent = dict.hint_touch;
|
||||
}
|
||||
applyDinoLang(urlParams.get('lang'));
|
||||
|
||||
window.addEventListener('message', e => {
|
||||
if (e.data && e.data.type === 'themeChange') {
|
||||
setTheme(e.data.theme, e.data.macosMode);
|
||||
}
|
||||
if (e.data && e.data.type === 'langChange') {
|
||||
applyDinoLang(e.data.lang);
|
||||
}
|
||||
});
|
||||
|
||||
function getThemeProp(name, fallback) {
|
||||
@@ -367,7 +408,7 @@
|
||||
let gameOver = false;
|
||||
let score = 0;
|
||||
let gameSpeed = 6;
|
||||
let nextObstacleTimer = 0;
|
||||
let nextObstacleTimer = 90; // Période de grâce au lancement
|
||||
let isNight = false;
|
||||
|
||||
// Dinosaur
|
||||
@@ -436,6 +477,7 @@
|
||||
gameStarted = true;
|
||||
score = 0;
|
||||
gameSpeed = 6;
|
||||
nextObstacleTimer = 90; // Période de grâce de 1.5s à chaque reprise
|
||||
obstacles = [];
|
||||
dino.y = GROUND_Y - 44;
|
||||
dino.vy = 0;
|
||||
@@ -448,12 +490,35 @@
|
||||
}
|
||||
|
||||
function spawnObstacle() {
|
||||
const type = (score > 250 && Math.random() < 0.3) ? 'ptero' : 'cactus';
|
||||
// Les ptérodactyles n'apparaissent qu'à partir de 450 points
|
||||
const allowPtero = score > 450;
|
||||
const type = (allowPtero && Math.random() < 0.28) ? 'ptero' : 'cactus';
|
||||
|
||||
if (type === 'cactus') {
|
||||
const isBig = Math.random() < 0.4;
|
||||
const count = isBig ? (Math.random() < 0.5 ? 2 : 1) : Math.floor(Math.random() * 3) + 1;
|
||||
let isBig = false;
|
||||
let count = 1;
|
||||
|
||||
// Difficulté progressive équitable
|
||||
if (score < 100) {
|
||||
// Début : 1 seul petit cactus (accessible pour s'échauffer)
|
||||
isBig = false;
|
||||
count = 1;
|
||||
} else if (score < 250) {
|
||||
// 1 cactus petit ou grand
|
||||
isBig = Math.random() < 0.45;
|
||||
count = 1;
|
||||
} else if (score < 450) {
|
||||
// 1 ou 2 cactus
|
||||
isBig = Math.random() < 0.4;
|
||||
count = Math.random() < 0.6 ? 1 : 2;
|
||||
} else {
|
||||
// Vitesse élevée : jusqu'à 3 petits ou 2 grands
|
||||
isBig = Math.random() < 0.45;
|
||||
count = isBig ? (Math.random() < 0.65 ? 1 : 2) : (Math.floor(Math.random() * 3) + 1);
|
||||
}
|
||||
|
||||
const w = (isBig ? 24 : 16) * count;
|
||||
const h = isBig ? 46 : 34;
|
||||
const h = isBig ? 44 : 32;
|
||||
obstacles.push({
|
||||
type: 'cactus',
|
||||
x: canvas.width + 20,
|
||||
@@ -463,8 +528,8 @@
|
||||
isBig: isBig
|
||||
});
|
||||
} else {
|
||||
// Pterodactyl fly height (low, mid, high)
|
||||
const heights = [GROUND_Y - 32, GROUND_Y - 55, GROUND_Y - 80];
|
||||
// Ptérodactyles : hauteurs adaptées (haut = passer dessous, bas = sauter par dessus)
|
||||
const heights = [GROUND_Y - 32, GROUND_Y - 55, GROUND_Y - 78];
|
||||
const h = heights[Math.floor(Math.random() * heights.length)];
|
||||
obstacles.push({
|
||||
type: 'ptero',
|
||||
@@ -479,7 +544,7 @@
|
||||
}
|
||||
|
||||
function checkCollision(r1, r2) {
|
||||
const p = 6;
|
||||
const p = 8; // Marge de tolérance équitable pour les collisions
|
||||
return (
|
||||
r1.x + p < r2.x + r2.width &&
|
||||
r1.x + r1.width - p > r2.x &&
|
||||
@@ -632,12 +697,14 @@
|
||||
dino.legTimer = 0;
|
||||
}
|
||||
|
||||
// Obstacle timer
|
||||
nextObstacleTimer -= gameSpeed;
|
||||
// Décompte de l'obstacle : 1 frame par itération pour un timing stable
|
||||
nextObstacleTimer -= 1;
|
||||
if (nextObstacleTimer <= 0) {
|
||||
spawnObstacle();
|
||||
// Random interval based on speed
|
||||
nextObstacleTimer = Math.floor(Math.random() * 60) + (100 - Math.min(gameSpeed * 5, 50));
|
||||
// Intervalle équitable garantissant au joueur le temps de réatterrir (minimum 50 frames même à pleine vitesse)
|
||||
const minFrames = Math.max(50, 95 - Math.floor(score / 40));
|
||||
const randomVariance = Math.floor(Math.random() * 45);
|
||||
nextObstacleTimer = minFrames + randomVariance;
|
||||
}
|
||||
|
||||
// Move obstacles
|
||||
|
||||
Reference in new issue
Block a user