APmanageur Wi-Fi V1.0
This commit is contained in:
1 parent
a72d161092
commit
33cf355785
4 files changed
+825
-266
No files matched your search
+297
-128
@@ -1,15 +1,159 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="fr">
|
||||
<html lang="fr" data-theme="dark">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
|
||||
<title>T-Rex Dino Runner - AP Manageur</title>
|
||||
<style>
|
||||
* { box-sizing: border-box; margin: 0; padding: 0; user-select: none; }
|
||||
|
||||
:root, html[data-theme="dark"] {
|
||||
--bg: #071326;
|
||||
--card-bg: #0d1d36;
|
||||
--panel-box: #132746;
|
||||
--border: #223c68;
|
||||
--text: #eef4ff;
|
||||
--muted: #9aa8c5;
|
||||
--blue: #5ca7ff;
|
||||
--blue-btn-text: #071326;
|
||||
--canvas-day: #0f2444;
|
||||
--canvas-night: #050d1a;
|
||||
--dino-color: #eef4ff;
|
||||
--dino-eye: #0f2444;
|
||||
--cactus-color: #34d399;
|
||||
--ptero-color: #ff6b6b;
|
||||
--ground-color: #5ca7ff;
|
||||
--ground-bump: #38bdf8;
|
||||
--cloud-color: #223c68;
|
||||
--star-color: #eef4ff;
|
||||
}
|
||||
html[data-theme="light"] {
|
||||
--bg: #f2f5fa;
|
||||
--card-bg: #ffffff;
|
||||
--panel-box: #e9eef7;
|
||||
--border: #d2dcec;
|
||||
--text: #15203a;
|
||||
--muted: #5b6b8c;
|
||||
--blue: #1e6ef0;
|
||||
--blue-btn-text: #ffffff;
|
||||
--canvas-day: #f8fafc;
|
||||
--canvas-night: #1e293b;
|
||||
--dino-color: #334155;
|
||||
--dino-eye: #f8fafc;
|
||||
--cactus-color: #16a34a;
|
||||
--ptero-color: #ef4444;
|
||||
--ground-color: #64748b;
|
||||
--ground-bump: #94a3b8;
|
||||
--cloud-color: #cbd5e1;
|
||||
--star-color: #f1f5f9;
|
||||
}
|
||||
html[data-theme="winxp"] {
|
||||
--bg: #ece9d8;
|
||||
--card-bg: #ece9d8;
|
||||
--panel-box: #ffffff;
|
||||
--border: #7f9db9;
|
||||
--text: #000000;
|
||||
--muted: #444444;
|
||||
--blue: #0055ea;
|
||||
--blue-btn-text: #ffffff;
|
||||
--canvas-day: #ffffff;
|
||||
--canvas-night: #0a246a;
|
||||
--dino-color: #111111;
|
||||
--dino-eye: #ffffff;
|
||||
--cactus-color: #198754;
|
||||
--ptero-color: #cc0000;
|
||||
--ground-color: #7f9db9;
|
||||
--ground-bump: #555555;
|
||||
--cloud-color: #dcdcdc;
|
||||
--star-color: #ffffdd;
|
||||
font-family: 'Tahoma', sans-serif !important;
|
||||
}
|
||||
html[data-theme="macos"][data-macos-mode="light"],
|
||||
html[data-theme="macos"]:not([data-macos-mode="dark"]) {
|
||||
--bg: #f5f5f7;
|
||||
--card-bg: #ffffff;
|
||||
--panel-box: #f2f2f7;
|
||||
--border: rgba(0, 0, 0, 0.12);
|
||||
--text: #1d1d1f;
|
||||
--muted: #86868b;
|
||||
--blue: #0071e3;
|
||||
--blue-btn-text: #ffffff;
|
||||
--canvas-day: #ffffff;
|
||||
--canvas-night: #2c2c2e;
|
||||
--dino-color: #1d1d1f;
|
||||
--dino-eye: #ffffff;
|
||||
--cactus-color: #34c759;
|
||||
--ptero-color: #ff3b30;
|
||||
--ground-color: #8e8e93;
|
||||
--ground-bump: #636366;
|
||||
--cloud-color: #e5e5ea;
|
||||
--star-color: #ffffff;
|
||||
}
|
||||
html[data-theme="macos"][data-macos-mode="dark"] {
|
||||
--bg: #1e1e1e;
|
||||
--card-bg: #2d2d2d;
|
||||
--panel-box: #3a3a3c;
|
||||
--border: rgba(255, 255, 255, 0.15);
|
||||
--text: #f5f5f7;
|
||||
--muted: #98989d;
|
||||
--blue: #0a84ff;
|
||||
--blue-btn-text: #ffffff;
|
||||
--canvas-day: #252527;
|
||||
--canvas-night: #141416;
|
||||
--dino-color: #f5f5f7;
|
||||
--dino-eye: #252527;
|
||||
--cactus-color: #30d158;
|
||||
--ptero-color: #ff453a;
|
||||
--ground-color: #636366;
|
||||
--ground-bump: #8e8e93;
|
||||
--cloud-color: #3a3a3c;
|
||||
--star-color: #ffffff;
|
||||
}
|
||||
html[data-theme="futuristic"] {
|
||||
--bg: #050811;
|
||||
--card-bg: #091124;
|
||||
--panel-box: #0f1c3a;
|
||||
--border: #00f0ff;
|
||||
--text: #e6f6ff;
|
||||
--muted: #64b5f6;
|
||||
--blue: #00f0ff;
|
||||
--blue-btn-text: #050811;
|
||||
--canvas-day: #030818;
|
||||
--canvas-night: #01040a;
|
||||
--dino-color: #00f0ff;
|
||||
--dino-eye: #030818;
|
||||
--cactus-color: #c084fc;
|
||||
--ptero-color: #f43f5e;
|
||||
--ground-color: #00f0ff;
|
||||
--ground-bump: #38bdf8;
|
||||
--cloud-color: #1e293b;
|
||||
--star-color: #00f0ff;
|
||||
}
|
||||
html[data-theme="hacker"] {
|
||||
--bg: #000000;
|
||||
--card-bg: #051206;
|
||||
--panel-box: #0a1f0c;
|
||||
--border: #00ff41;
|
||||
--text: #00ff41;
|
||||
--muted: #008f11;
|
||||
--blue: #00ff41;
|
||||
--blue-btn-text: #000000;
|
||||
--canvas-day: #020d04;
|
||||
--canvas-night: #000000;
|
||||
--dino-color: #00ff41;
|
||||
--dino-eye: #020d04;
|
||||
--cactus-color: #00bb30;
|
||||
--ptero-color: #ff0055;
|
||||
--ground-color: #00ff41;
|
||||
--ground-bump: #00ff41;
|
||||
--cloud-color: #00330d;
|
||||
--star-color: #00ff41;
|
||||
}
|
||||
|
||||
body {
|
||||
background: #071326;
|
||||
color: #eef4ff;
|
||||
font-family: "Courier New", Courier, monospace, -apple-system, sans-serif;
|
||||
background: var(--bg);
|
||||
color: var(--text);
|
||||
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, monospace;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
@@ -17,16 +161,18 @@
|
||||
min-height: 100vh;
|
||||
overflow: hidden;
|
||||
padding: 10px;
|
||||
transition: background 0.3s ease, color 0.3s ease;
|
||||
}
|
||||
.game-card {
|
||||
background: #0d1d36;
|
||||
border: 1px solid #223c68;
|
||||
background: var(--card-bg);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: 14px;
|
||||
padding: 16px;
|
||||
box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5), 0 0 20px rgba(92, 167, 255, 0.15);
|
||||
box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5), 0 0 20px rgba(92, 167, 255, 0.12);
|
||||
position: relative;
|
||||
max-width: 700px;
|
||||
width: 100%;
|
||||
transition: all 0.3s ease;
|
||||
}
|
||||
.header-bar {
|
||||
display: flex;
|
||||
@@ -34,28 +180,29 @@
|
||||
align-items: center;
|
||||
margin-bottom: 12px;
|
||||
font-size: 14px;
|
||||
color: #9aa8c5;
|
||||
color: var(--muted);
|
||||
}
|
||||
.scores {
|
||||
font-size: 18px;
|
||||
font-weight: 700;
|
||||
letter-spacing: 2px;
|
||||
color: #5ca7ff;
|
||||
color: var(--blue);
|
||||
font-family: monospace;
|
||||
}
|
||||
.scores .hi {
|
||||
color: #9aa8c5;
|
||||
color: var(--muted);
|
||||
margin-right: 12px;
|
||||
}
|
||||
.canvas-wrap {
|
||||
position: relative;
|
||||
background: #f7f7f7;
|
||||
border: 2px solid #223c68;
|
||||
background: var(--canvas-day);
|
||||
border: 2px solid var(--border);
|
||||
border-radius: 8px;
|
||||
overflow: hidden;
|
||||
transition: background 0.6s ease;
|
||||
transition: background 0.6s ease, border-color 0.3s ease;
|
||||
}
|
||||
body.night-mode .canvas-wrap {
|
||||
background: #111827;
|
||||
background: var(--canvas-night);
|
||||
}
|
||||
canvas {
|
||||
display: block;
|
||||
@@ -69,14 +216,14 @@
|
||||
align-items: center;
|
||||
margin-top: 12px;
|
||||
font-size: 12px;
|
||||
color: #9aa8c5;
|
||||
color: var(--muted);
|
||||
flex-wrap: wrap;
|
||||
gap: 8px;
|
||||
}
|
||||
.controls-hint kbd {
|
||||
background: #132746;
|
||||
border: 1px solid #223c68;
|
||||
color: #fff;
|
||||
background: var(--panel-box);
|
||||
border: 1px solid var(--border);
|
||||
color: var(--text);
|
||||
padding: 2px 6px;
|
||||
border-radius: 4px;
|
||||
font-size: 11px;
|
||||
@@ -89,7 +236,7 @@
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
background: rgba(7, 19, 38, 0.85);
|
||||
backdrop-filter: blur(2px);
|
||||
backdrop-filter: blur(3px);
|
||||
z-index: 10;
|
||||
gap: 12px;
|
||||
}
|
||||
@@ -99,8 +246,8 @@
|
||||
letter-spacing: 3px;
|
||||
}
|
||||
.restart-btn {
|
||||
background: #5ca7ff;
|
||||
color: #071326;
|
||||
background: var(--blue);
|
||||
color: var(--blue-btn-text);
|
||||
border: 0;
|
||||
padding: 8px 20px;
|
||||
border-radius: 6px;
|
||||
@@ -110,8 +257,10 @@
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
|
||||
transition: opacity 0.15s ease;
|
||||
}
|
||||
.restart-btn:hover { background: #7ab7ff; }
|
||||
.restart-btn:hover { opacity: 0.9; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
@@ -141,6 +290,31 @@
|
||||
</div>
|
||||
|
||||
<script>
|
||||
// Theme Management
|
||||
function setTheme(theme, macosMode) {
|
||||
if (!theme) theme = 'dark';
|
||||
document.documentElement.dataset.theme = theme;
|
||||
if (theme === 'macos' && macosMode) {
|
||||
document.documentElement.dataset.macosMode = macosMode;
|
||||
} else {
|
||||
delete document.documentElement.dataset.macosMode;
|
||||
}
|
||||
}
|
||||
|
||||
const urlParams = new URLSearchParams(window.location.search);
|
||||
setTheme(urlParams.get('theme') || 'dark', urlParams.get('macosMode'));
|
||||
|
||||
window.addEventListener('message', e => {
|
||||
if (e.data && e.data.type === 'themeChange') {
|
||||
setTheme(e.data.theme, e.data.macosMode);
|
||||
}
|
||||
});
|
||||
|
||||
function getThemeProp(name, fallback) {
|
||||
const val = getComputedStyle(document.documentElement).getPropertyValue(name).trim();
|
||||
return val || fallback;
|
||||
}
|
||||
|
||||
// Audio synthesizer
|
||||
let audioCtx = null;
|
||||
function playTone(type) {
|
||||
@@ -203,36 +377,30 @@
|
||||
width: 44,
|
||||
height: 44,
|
||||
vy: 0,
|
||||
gravity: 0.72,
|
||||
jumpStrength: -11.5,
|
||||
jumpForce: -11.5,
|
||||
gravity: 0.65,
|
||||
isGrounded: true,
|
||||
isDucking: false,
|
||||
legFrame: 0,
|
||||
legTimer: 0
|
||||
};
|
||||
|
||||
// Obstacles
|
||||
let obstacles = [];
|
||||
let clouds = [];
|
||||
let clouds = [
|
||||
{ x: 120, y: 50, speed: 0.8 },
|
||||
{ x: 380, y: 70, speed: 0.6 },
|
||||
{ x: 550, y: 40, speed: 0.7 }
|
||||
];
|
||||
let stars = [];
|
||||
|
||||
// Init clouds
|
||||
for (let i = 0; i < 4; i++) {
|
||||
clouds.push({
|
||||
x: Math.random() * canvas.width,
|
||||
y: 20 + Math.random() * 60,
|
||||
speed: 0.5 + Math.random() * 0.8
|
||||
});
|
||||
}
|
||||
// Init stars for night mode
|
||||
for (let i = 0; i < 20; i++) {
|
||||
for (let i = 0; i < 25; i++) {
|
||||
stars.push({
|
||||
x: Math.random() * canvas.width,
|
||||
y: Math.random() * 120,
|
||||
x: Math.random() * 640,
|
||||
y: Math.random() * 120 + 10,
|
||||
r: Math.random() * 1.5 + 0.5
|
||||
});
|
||||
}
|
||||
|
||||
// Ground bumps
|
||||
let groundOffset = 0;
|
||||
|
||||
function jump() {
|
||||
@@ -243,72 +411,75 @@
|
||||
resetGame();
|
||||
return;
|
||||
}
|
||||
if (dino.isGrounded) {
|
||||
dino.vy = dino.jumpStrength;
|
||||
if (dino.isGrounded && !dino.isDucking) {
|
||||
dino.vy = dino.jumpForce;
|
||||
dino.isGrounded = false;
|
||||
playTone('jump');
|
||||
}
|
||||
}
|
||||
|
||||
function duck(down) {
|
||||
function duck(isDucking) {
|
||||
if (!gameStarted || gameOver) return;
|
||||
dino.isDucking = down;
|
||||
if (down && !dino.isGrounded) {
|
||||
dino.vy += 4.5; // Fast drop
|
||||
dino.isDucking = isDucking;
|
||||
if (isDucking) {
|
||||
dino.height = 28;
|
||||
if (!dino.isGrounded) {
|
||||
dino.vy += 4; // Fast fall
|
||||
}
|
||||
} else {
|
||||
dino.height = 44;
|
||||
}
|
||||
}
|
||||
|
||||
function resetGame() {
|
||||
gameOver = false;
|
||||
gameStarted = true;
|
||||
score = 0;
|
||||
gameSpeed = 6;
|
||||
nextObstacleTimer = 50;
|
||||
obstacles = [];
|
||||
dino.y = GROUND_Y - 44;
|
||||
dino.vy = 0;
|
||||
dino.isGrounded = true;
|
||||
dino.isDucking = false;
|
||||
gameOver = false;
|
||||
gameStarted = true;
|
||||
isNight = false;
|
||||
document.body.classList.remove('night-mode');
|
||||
dino.height = 44;
|
||||
overlay.style.display = 'none';
|
||||
document.body.classList.remove('night-mode');
|
||||
isNight = false;
|
||||
}
|
||||
|
||||
function spawnObstacle() {
|
||||
const isPterodactyl = score > 250 && Math.random() < 0.35;
|
||||
if (isPterodactyl) {
|
||||
const flyHeights = [GROUND_Y - 26, GROUND_Y - 50, GROUND_Y - 72];
|
||||
const flyY = flyHeights[Math.floor(Math.random() * flyHeights.length)];
|
||||
obstacles.push({
|
||||
type: 'ptero',
|
||||
x: canvas.width + 20,
|
||||
y: flyY,
|
||||
width: 36,
|
||||
height: 26,
|
||||
frame: 0,
|
||||
frameTimer: 0
|
||||
});
|
||||
} else {
|
||||
const kinds = [
|
||||
{ width: 16, height: 35 },
|
||||
{ width: 32, height: 35 },
|
||||
{ width: 48, height: 35 },
|
||||
{ width: 22, height: 46 } // Tall
|
||||
];
|
||||
const kind = kinds[Math.floor(Math.random() * kinds.length)];
|
||||
const type = (score > 250 && Math.random() < 0.3) ? '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;
|
||||
const w = (isBig ? 24 : 16) * count;
|
||||
const h = isBig ? 46 : 34;
|
||||
obstacles.push({
|
||||
type: 'cactus',
|
||||
x: canvas.width + 20,
|
||||
y: GROUND_Y - kind.height,
|
||||
width: kind.width,
|
||||
height: kind.height
|
||||
y: GROUND_Y - h,
|
||||
width: w,
|
||||
height: h,
|
||||
isBig: isBig
|
||||
});
|
||||
} else {
|
||||
// Pterodactyl fly height (low, mid, high)
|
||||
const heights = [GROUND_Y - 32, GROUND_Y - 55, GROUND_Y - 80];
|
||||
const h = heights[Math.floor(Math.random() * heights.length)];
|
||||
obstacles.push({
|
||||
type: 'ptero',
|
||||
x: canvas.width + 20,
|
||||
y: h,
|
||||
width: 40,
|
||||
height: 28,
|
||||
frame: 0,
|
||||
frameTimer: 0
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function checkCollision(r1, r2) {
|
||||
// Small margin of forgiveness (hitbox padding)
|
||||
const p = 4;
|
||||
const p = 6;
|
||||
return (
|
||||
r1.x + p < r2.x + r2.width &&
|
||||
r1.x + r1.width - p > r2.x &&
|
||||
@@ -318,7 +489,9 @@
|
||||
}
|
||||
|
||||
function drawPixelDino(x, y, w, h, isDucking, legFrame, isDead) {
|
||||
ctx.fillStyle = isNight ? '#e5e7eb' : '#535353';
|
||||
const dinoColor = getThemeProp('--dino-color', '#eef4ff');
|
||||
const eyeColor = isNight ? getThemeProp('--canvas-night', '#050d1a') : getThemeProp('--canvas-day', '#0f2444');
|
||||
ctx.fillStyle = dinoColor;
|
||||
|
||||
if (isDucking && dino.isGrounded) {
|
||||
// Ducking body
|
||||
@@ -326,9 +499,9 @@
|
||||
// Head low
|
||||
ctx.fillRect(x + 40, y + 10, 18, 14);
|
||||
// Eye
|
||||
ctx.fillStyle = isNight ? '#111827' : '#f7f7f7';
|
||||
ctx.fillStyle = eyeColor;
|
||||
ctx.fillRect(x + 48, y + 12, 3, 3);
|
||||
ctx.fillStyle = isNight ? '#e5e7eb' : '#535353';
|
||||
ctx.fillStyle = dinoColor;
|
||||
// Legs
|
||||
if (legFrame === 0) {
|
||||
ctx.fillRect(x + 10, y + 36, 4, 8);
|
||||
@@ -345,13 +518,12 @@
|
||||
ctx.fillRect(x + 22, y, 22, 16);
|
||||
ctx.fillRect(x + 18, y + 6, 6, 10);
|
||||
// Eye
|
||||
ctx.fillStyle = isNight ? '#111827' : '#f7f7f7';
|
||||
ctx.fillStyle = eyeColor;
|
||||
ctx.fillRect(x + 26, y + 3, isDead ? 5 : 3, 3);
|
||||
if (isDead) {
|
||||
// X eye
|
||||
ctx.fillRect(x + 28, y + 2, 2, 5);
|
||||
}
|
||||
ctx.fillStyle = isNight ? '#e5e7eb' : '#535353';
|
||||
ctx.fillStyle = dinoColor;
|
||||
|
||||
// Snout / mouth
|
||||
ctx.fillRect(x + 36, y + 8, 8, 6);
|
||||
@@ -379,7 +551,7 @@
|
||||
}
|
||||
|
||||
function drawCactus(x, y, w, h) {
|
||||
ctx.fillStyle = isNight ? '#34d399' : '#10b981';
|
||||
ctx.fillStyle = getThemeProp('--cactus-color', '#34d399');
|
||||
// Main stem
|
||||
ctx.fillRect(x + w * 0.35, y, w * 0.3, h);
|
||||
// Branches
|
||||
@@ -392,7 +564,7 @@
|
||||
}
|
||||
|
||||
function drawPterodactyl(p) {
|
||||
ctx.fillStyle = isNight ? '#f87171' : '#ef4444';
|
||||
ctx.fillStyle = getThemeProp('--ptero-color', '#ff6b6b');
|
||||
const x = p.x, y = p.y;
|
||||
// Body
|
||||
ctx.fillRect(x + 10, y + 8, 16, 8);
|
||||
@@ -408,7 +580,7 @@
|
||||
}
|
||||
|
||||
function drawCloud(c) {
|
||||
ctx.fillStyle = isNight ? '#374151' : '#d1d5db';
|
||||
ctx.fillStyle = getThemeProp('--cloud-color', '#223c68');
|
||||
ctx.beginPath();
|
||||
ctx.arc(c.x, c.y, 10, 0, Math.PI * 2);
|
||||
ctx.arc(c.x + 10, c.y - 6, 12, 0, Math.PI * 2);
|
||||
@@ -424,75 +596,72 @@
|
||||
const currentIntScore = Math.floor(score);
|
||||
currentScoreEl.textContent = String(currentIntScore).padStart(5, '0');
|
||||
|
||||
// Milestone chime
|
||||
if (currentIntScore > 0 && currentIntScore % 100 === 0 && Math.floor(score - 0.2) % 100 !== 0) {
|
||||
// High score
|
||||
if (currentIntScore > highScore) {
|
||||
highScore = currentIntScore;
|
||||
hiScoreEl.textContent = String(highScore).padStart(5, '0');
|
||||
localStorage.setItem('ap_dino_hi', highScore);
|
||||
}
|
||||
|
||||
// Night mode toggle every 700 points
|
||||
const nightCycle = Math.floor(score / 700) % 2 === 1;
|
||||
if (nightCycle !== isNight) {
|
||||
isNight = nightCycle;
|
||||
document.body.classList.toggle('night-mode', isNight);
|
||||
}
|
||||
|
||||
// Score milestone beep
|
||||
if (currentIntScore > 0 && currentIntScore % 100 === 0 && Math.floor((score - 0.2)) % 100 !== 0) {
|
||||
playTone('score');
|
||||
}
|
||||
|
||||
// Day/night shift
|
||||
const nightPeriod = Math.floor(currentIntScore / 500) % 2 === 1;
|
||||
if (nightPeriod !== isNight) {
|
||||
isNight = nightPeriod;
|
||||
if (isNight) document.body.classList.add('night-mode');
|
||||
else document.body.classList.remove('night-mode');
|
||||
}
|
||||
|
||||
// Dino physics
|
||||
dino.vy += dino.gravity;
|
||||
dino.y += dino.vy;
|
||||
const effectiveH = dino.isDucking ? 26 : 44;
|
||||
if (dino.y >= GROUND_Y - effectiveH) {
|
||||
dino.y = GROUND_Y - effectiveH;
|
||||
dino.vy += dino.gravity;
|
||||
|
||||
if (dino.y >= GROUND_Y - dino.height) {
|
||||
dino.y = GROUND_Y - dino.height;
|
||||
dino.vy = 0;
|
||||
dino.isGrounded = true;
|
||||
}
|
||||
|
||||
// Leg animation
|
||||
dino.legTimer += gameSpeed;
|
||||
if (dino.legTimer > 40) {
|
||||
// Dino animation legs
|
||||
dino.legTimer++;
|
||||
if (dino.legTimer > 5) {
|
||||
dino.legFrame = (dino.legFrame === 0) ? 1 : 0;
|
||||
dino.legTimer = 0;
|
||||
dino.legFrame = dino.legFrame === 0 ? 1 : 0;
|
||||
}
|
||||
|
||||
// Spawn obstacles
|
||||
nextObstacleTimer -= 1;
|
||||
// Obstacle timer
|
||||
nextObstacleTimer -= gameSpeed;
|
||||
if (nextObstacleTimer <= 0) {
|
||||
spawnObstacle();
|
||||
nextObstacleTimer = Math.max(45, Math.floor(65 + Math.random() * 85 - (gameSpeed * 2)));
|
||||
// Random interval based on speed
|
||||
nextObstacleTimer = Math.floor(Math.random() * 60) + (100 - Math.min(gameSpeed * 5, 50));
|
||||
}
|
||||
|
||||
// Update obstacles
|
||||
// Move obstacles
|
||||
for (let i = obstacles.length - 1; i >= 0; i--) {
|
||||
const obs = obstacles[i];
|
||||
obs.x -= gameSpeed;
|
||||
|
||||
if (obs.type === 'ptero') {
|
||||
obs.frameTimer += 1;
|
||||
if (obs.frameTimer > 10) {
|
||||
obs.frameTimer = (obs.frameTimer || 0) + 1;
|
||||
if (obs.frameTimer > 12) {
|
||||
obs.frame = (obs.frame === 0) ? 1 : 0;
|
||||
obs.frameTimer = 0;
|
||||
obs.frame = obs.frame === 0 ? 1 : 0;
|
||||
}
|
||||
}
|
||||
|
||||
// Collision check
|
||||
const dinoBox = {
|
||||
x: dino.x,
|
||||
y: dino.y,
|
||||
width: dino.isDucking ? 54 : dino.width,
|
||||
height: dino.isDucking ? 26 : dino.height
|
||||
};
|
||||
if (checkCollision(dinoBox, obs)) {
|
||||
// Collision detection
|
||||
if (checkCollision(dino, obs)) {
|
||||
gameOver = true;
|
||||
playTone('hit');
|
||||
overlay.style.display = 'flex';
|
||||
if (currentIntScore > highScore) {
|
||||
highScore = currentIntScore;
|
||||
localStorage.setItem('ap_dino_hi', highScore);
|
||||
hiScoreEl.textContent = String(highScore).padStart(5, '0');
|
||||
}
|
||||
}
|
||||
|
||||
if (obs.x + obs.width < -30) {
|
||||
// Offscreen removal
|
||||
if (obs.x + obs.width < -10) {
|
||||
obstacles.splice(i, 1);
|
||||
}
|
||||
}
|
||||
@@ -512,7 +681,7 @@
|
||||
|
||||
// Stars in night mode
|
||||
if (isNight) {
|
||||
ctx.fillStyle = '#f9fafb';
|
||||
ctx.fillStyle = getThemeProp('--star-color', '#eef4ff');
|
||||
stars.forEach(s => {
|
||||
ctx.beginPath();
|
||||
ctx.arc(s.x, s.y, s.r, 0, Math.PI * 2);
|
||||
@@ -523,7 +692,7 @@
|
||||
ctx.beginPath();
|
||||
ctx.arc(560, 40, 16, 0, Math.PI * 2);
|
||||
ctx.fill();
|
||||
ctx.fillStyle = '#111827';
|
||||
ctx.fillStyle = getThemeProp('--canvas-night', '#050d1a');
|
||||
ctx.beginPath();
|
||||
ctx.arc(553, 37, 13, 0, Math.PI * 2);
|
||||
ctx.fill();
|
||||
@@ -533,7 +702,7 @@
|
||||
clouds.forEach(drawCloud);
|
||||
|
||||
// Ground Line
|
||||
ctx.strokeStyle = isNight ? '#4b5563' : '#737373';
|
||||
ctx.strokeStyle = getThemeProp('--ground-color', '#5ca7ff');
|
||||
ctx.lineWidth = 2;
|
||||
ctx.beginPath();
|
||||
ctx.moveTo(0, GROUND_Y);
|
||||
@@ -541,7 +710,7 @@
|
||||
ctx.stroke();
|
||||
|
||||
// Ground texture bumps
|
||||
ctx.fillStyle = isNight ? '#4b5563' : '#737373';
|
||||
ctx.fillStyle = getThemeProp('--ground-bump', '#38bdf8');
|
||||
for (let x = -groundOffset; x < canvas.width; x += 30) {
|
||||
ctx.fillRect(x + 5, GROUND_Y + 4, 8, 2);
|
||||
ctx.fillRect(x + 18, GROUND_Y + 9, 4, 1.5);
|
||||
|
||||
Reference in new issue
Block a user