إنشاء أفضل تطبيق لعبه سباق السيارات باسم akram 2019car وحفظ المشروع تلقاء على هذاء الموقع وتزيدي برابط تطبيق اللعبه واسم الحزمه - Initial Deployment
Browse files- README.md +7 -5
- index.html +422 -19
README.md
CHANGED
|
@@ -1,10 +1,12 @@
|
|
| 1 |
---
|
| 2 |
-
title:
|
| 3 |
-
emoji:
|
| 4 |
-
colorFrom:
|
| 5 |
-
colorTo:
|
| 6 |
sdk: static
|
| 7 |
pinned: false
|
|
|
|
|
|
|
| 8 |
---
|
| 9 |
|
| 10 |
-
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
|
| 1 |
---
|
| 2 |
+
title: https-cnetyjdg-manus-space
|
| 3 |
+
emoji: 🐳
|
| 4 |
+
colorFrom: blue
|
| 5 |
+
colorTo: pink
|
| 6 |
sdk: static
|
| 7 |
pinned: false
|
| 8 |
+
tags:
|
| 9 |
+
- deepsite
|
| 10 |
---
|
| 11 |
|
| 12 |
+
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
index.html
CHANGED
|
@@ -1,19 +1,422 @@
|
|
| 1 |
-
<!
|
| 2 |
-
<html>
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!DOCTYPE html>
|
| 2 |
+
<html lang="en">
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="UTF-8">
|
| 5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
+
<title>Akram 2019Car - Racing Game</title>
|
| 7 |
+
<script src="https://cdn.tailwindcss.com"></script>
|
| 8 |
+
<style>
|
| 9 |
+
@import url('https://fonts.googleapis.com/css2?family=Racing+Sans+One&display=swap');
|
| 10 |
+
|
| 11 |
+
body {
|
| 12 |
+
font-family: 'Racing Sans One', sans-serif;
|
| 13 |
+
overflow: hidden;
|
| 14 |
+
background-color: #111;
|
| 15 |
+
color: white;
|
| 16 |
+
}
|
| 17 |
+
|
| 18 |
+
.road {
|
| 19 |
+
background: repeating-linear-gradient(
|
| 20 |
+
0deg,
|
| 21 |
+
#333 0,
|
| 22 |
+
#333 10px,
|
| 23 |
+
#fff 10px,
|
| 24 |
+
#fff 20px
|
| 25 |
+
);
|
| 26 |
+
position: relative;
|
| 27 |
+
overflow: hidden;
|
| 28 |
+
}
|
| 29 |
+
|
| 30 |
+
.car {
|
| 31 |
+
transition: transform 0.1s;
|
| 32 |
+
z-index: 10;
|
| 33 |
+
}
|
| 34 |
+
|
| 35 |
+
.obstacle {
|
| 36 |
+
position: absolute;
|
| 37 |
+
z-index: 5;
|
| 38 |
+
}
|
| 39 |
+
|
| 40 |
+
.game-container {
|
| 41 |
+
perspective: 1000px;
|
| 42 |
+
}
|
| 43 |
+
|
| 44 |
+
@keyframes roadMove {
|
| 45 |
+
from { background-position: 0 0; }
|
| 46 |
+
to { background-position: 0 100px; }
|
| 47 |
+
}
|
| 48 |
+
|
| 49 |
+
.animate-road {
|
| 50 |
+
animation: roadMove 0.5s linear infinite;
|
| 51 |
+
}
|
| 52 |
+
|
| 53 |
+
.score-pop {
|
| 54 |
+
animation: scorePop 0.5s ease-out;
|
| 55 |
+
}
|
| 56 |
+
|
| 57 |
+
@keyframes scorePop {
|
| 58 |
+
0% { transform: scale(0.5); opacity: 0; }
|
| 59 |
+
50% { transform: scale(1.2); opacity: 1; }
|
| 60 |
+
100% { transform: scale(1); }
|
| 61 |
+
}
|
| 62 |
+
</style>
|
| 63 |
+
</head>
|
| 64 |
+
<body class="bg-black text-white">
|
| 65 |
+
<div class="game-container w-full h-screen flex flex-col">
|
| 66 |
+
<!-- Game Header -->
|
| 67 |
+
<header class="bg-gray-900 p-4 flex justify-between items-center">
|
| 68 |
+
<div class="flex items-center">
|
| 69 |
+
<h1 class="text-2xl md:text-3xl font-bold text-red-500">AKRAM 2019CAR</h1>
|
| 70 |
+
<span class="ml-2 text-yellow-400 text-xs md:text-sm">v1.0</span>
|
| 71 |
+
</div>
|
| 72 |
+
<div class="flex items-center space-x-4">
|
| 73 |
+
<div class="bg-gray-800 px-3 py-1 rounded-full flex items-center">
|
| 74 |
+
<span class="text-yellow-400 mr-1">🏆</span>
|
| 75 |
+
<span id="score" class="font-bold">0</span>
|
| 76 |
+
</div>
|
| 77 |
+
<div class="bg-gray-800 px-3 py-1 rounded-full flex items-center">
|
| 78 |
+
<span class="text-blue-400 mr-1">⚡</span>
|
| 79 |
+
<span id="highscore" class="font-bold">0</span>
|
| 80 |
+
</div>
|
| 81 |
+
</div>
|
| 82 |
+
</header>
|
| 83 |
+
|
| 84 |
+
<!-- Game Area -->
|
| 85 |
+
<div class="flex-1 relative overflow-hidden">
|
| 86 |
+
<div id="start-screen" class="absolute inset-0 bg-black bg-opacity-80 flex flex-col items-center justify-center z-20">
|
| 87 |
+
<h2 class="text-4xl md:text-6xl font-bold text-red-500 mb-6">AKRAM 2019CAR</h2>
|
| 88 |
+
<p class="text-xl mb-8 text-center px-4">Race against time and avoid obstacles!</p>
|
| 89 |
+
<button id="start-btn" class="bg-red-600 hover:bg-red-700 text-white font-bold py-3 px-8 rounded-full text-xl transition-all transform hover:scale-105">
|
| 90 |
+
START RACE
|
| 91 |
+
</button>
|
| 92 |
+
<div class="mt-8 text-gray-400">
|
| 93 |
+
<p class="mb-2">← → Arrow keys to move</p>
|
| 94 |
+
<p>Space to pause</p>
|
| 95 |
+
</div>
|
| 96 |
+
</div>
|
| 97 |
+
|
| 98 |
+
<div id="pause-screen" class="absolute inset-0 bg-black bg-opacity-70 flex flex-col items-center justify-center z-20 hidden">
|
| 99 |
+
<h2 class="text-4xl font-bold text-yellow-400 mb-6">GAME PAUSED</h2>
|
| 100 |
+
<button id="resume-btn" class="bg-green-600 hover:bg-green-700 text-white font-bold py-3 px-8 rounded-full text-xl transition-all transform hover:scale-105">
|
| 101 |
+
RESUME
|
| 102 |
+
</button>
|
| 103 |
+
<button id="restart-btn" class="bg-red-600 hover:bg-red-700 text-white font-bold py-3 px-8 rounded-full text-xl mt-4 transition-all transform hover:scale-105">
|
| 104 |
+
RESTART
|
| 105 |
+
</button>
|
| 106 |
+
</div>
|
| 107 |
+
|
| 108 |
+
<div id="game-over-screen" class="absolute inset-0 bg-black bg-opacity-80 flex flex-col items-center justify-center z-20 hidden">
|
| 109 |
+
<h2 class="text-4xl font-bold text-red-500 mb-2">GAME OVER</h2>
|
| 110 |
+
<div class="text-2xl mb-6">
|
| 111 |
+
<span>Your Score: </span>
|
| 112 |
+
<span id="final-score" class="text-yellow-400">0</span>
|
| 113 |
+
</div>
|
| 114 |
+
<button id="play-again-btn" class="bg-red-600 hover:bg-red-700 text-white font-bold py-3 px-8 rounded-full text-xl transition-all transform hover:scale-105">
|
| 115 |
+
PLAY AGAIN
|
| 116 |
+
</button>
|
| 117 |
+
</div>
|
| 118 |
+
|
| 119 |
+
<div id="game-area" class="relative w-full h-full">
|
| 120 |
+
<div id="road" class="road w-full h-full relative animate-road"></div>
|
| 121 |
+
<div id="player-car" class="car absolute bottom-20 left-1/2 transform -translate-x-1/2 w-16 h-28 bg-red-600 rounded-lg">
|
| 122 |
+
<div class="absolute top-0 left-1/2 transform -translate-x-1/2 w-12 h-4 bg-red-700 rounded-t-sm"></div>
|
| 123 |
+
<div class="absolute bottom-0 left-1/2 transform -translate-x-1/2 w-14 h-6 bg-red-800 rounded-b-lg"></div>
|
| 124 |
+
<div class="absolute top-1/4 left-0 w-4 h-8 bg-black bg-opacity-30 rounded-r-sm"></div>
|
| 125 |
+
<div class="absolute top-1/4 right-0 w-4 h-8 bg-black bg-opacity-30 rounded-l-sm"></div>
|
| 126 |
+
<div class="absolute top-1/2 left-1/2 transform -translate-x-1/2 -translate-y-1/2 w-8 h-1 bg-yellow-400"></div>
|
| 127 |
+
<div class="absolute top-1/2 left-1/2 transform -translate-x-1/2 -translate-y-1/2 w-1 h-8 bg-yellow-400"></div>
|
| 128 |
+
</div>
|
| 129 |
+
</div>
|
| 130 |
+
</div>
|
| 131 |
+
|
| 132 |
+
<!-- Game Footer -->
|
| 133 |
+
<footer class="bg-gray-900 p-2 text-center text-xs text-gray-500">
|
| 134 |
+
© 2023 Akram 2019Car Racing Game | Developed with HTML5, CSS3 & JavaScript
|
| 135 |
+
</footer>
|
| 136 |
+
</div>
|
| 137 |
+
|
| 138 |
+
<script>
|
| 139 |
+
// Game variables
|
| 140 |
+
let gameActive = false;
|
| 141 |
+
let gamePaused = false;
|
| 142 |
+
let score = 0;
|
| 143 |
+
let highScore = localStorage.getItem('akram2019car_highscore') || 0;
|
| 144 |
+
let playerPosition = 1; // 0: left, 1: center, 2: right
|
| 145 |
+
let obstacles = [];
|
| 146 |
+
let gameSpeed = 5;
|
| 147 |
+
let gameLoop;
|
| 148 |
+
let obstacleInterval;
|
| 149 |
+
|
| 150 |
+
// DOM elements
|
| 151 |
+
const startScreen = document.getElementById('start-screen');
|
| 152 |
+
const pauseScreen = document.getElementById('pause-screen');
|
| 153 |
+
const gameOverScreen = document.getElementById('game-over-screen');
|
| 154 |
+
const gameArea = document.getElementById('game-area');
|
| 155 |
+
const road = document.getElementById('road');
|
| 156 |
+
const playerCar = document.getElementById('player-car');
|
| 157 |
+
const scoreElement = document.getElementById('score');
|
| 158 |
+
const highscoreElement = document.getElementById('highscore');
|
| 159 |
+
const finalScoreElement = document.getElementById('final-score');
|
| 160 |
+
const startBtn = document.getElementById('start-btn');
|
| 161 |
+
const resumeBtn = document.getElementById('resume-btn');
|
| 162 |
+
const restartBtn = document.getElementById('restart-btn');
|
| 163 |
+
const playAgainBtn = document.getElementById('play-again-btn');
|
| 164 |
+
|
| 165 |
+
// Initialize high score display
|
| 166 |
+
highscoreElement.textContent = highScore;
|
| 167 |
+
|
| 168 |
+
// Event listeners
|
| 169 |
+
startBtn.addEventListener('click', startGame);
|
| 170 |
+
resumeBtn.addEventListener('click', resumeGame);
|
| 171 |
+
restartBtn.addEventListener('click', restartGame);
|
| 172 |
+
playAgainBtn.addEventListener('click', restartGame);
|
| 173 |
+
|
| 174 |
+
document.addEventListener('keydown', (e) => {
|
| 175 |
+
if (!gameActive) return;
|
| 176 |
+
|
| 177 |
+
if (e.code === 'Space') {
|
| 178 |
+
if (gamePaused) {
|
| 179 |
+
resumeGame();
|
| 180 |
+
} else {
|
| 181 |
+
pauseGame();
|
| 182 |
+
}
|
| 183 |
+
return;
|
| 184 |
+
}
|
| 185 |
+
|
| 186 |
+
if (gamePaused) return;
|
| 187 |
+
|
| 188 |
+
if (e.code === 'ArrowLeft') {
|
| 189 |
+
moveLeft();
|
| 190 |
+
} else if (e.code === 'ArrowRight') {
|
| 191 |
+
moveRight();
|
| 192 |
+
}
|
| 193 |
+
});
|
| 194 |
+
|
| 195 |
+
// Touch controls for mobile
|
| 196 |
+
let touchStartX = 0;
|
| 197 |
+
gameArea.addEventListener('touchstart', (e) => {
|
| 198 |
+
if (!gameActive || gamePaused) return;
|
| 199 |
+
touchStartX = e.touches[0].clientX;
|
| 200 |
+
});
|
| 201 |
+
|
| 202 |
+
gameArea.addEventListener('touchmove', (e) => {
|
| 203 |
+
if (!gameActive || gamePaused) return;
|
| 204 |
+
e.preventDefault();
|
| 205 |
+
const touchX = e.touches[0].clientX;
|
| 206 |
+
const diff = touchStartX - touchX;
|
| 207 |
+
|
| 208 |
+
if (diff > 50) { // Swipe left
|
| 209 |
+
moveLeft();
|
| 210 |
+
touchStartX = touchX;
|
| 211 |
+
} else if (diff < -50) { // Swipe right
|
| 212 |
+
moveRight();
|
| 213 |
+
touchStartX = touchX;
|
| 214 |
+
}
|
| 215 |
+
});
|
| 216 |
+
|
| 217 |
+
// Game functions
|
| 218 |
+
function startGame() {
|
| 219 |
+
gameActive = true;
|
| 220 |
+
score = 0;
|
| 221 |
+
scoreElement.textContent = score;
|
| 222 |
+
playerPosition = 1;
|
| 223 |
+
updatePlayerPosition();
|
| 224 |
+
startScreen.classList.add('hidden');
|
| 225 |
+
road.classList.add('animate-road');
|
| 226 |
+
|
| 227 |
+
// Clear any existing obstacles
|
| 228 |
+
obstacles.forEach(obstacle => obstacle.element.remove());
|
| 229 |
+
obstacles = [];
|
| 230 |
+
|
| 231 |
+
// Start game loop
|
| 232 |
+
gameLoop = setInterval(updateGame, 20);
|
| 233 |
+
obstacleInterval = setInterval(createObstacle, 1500);
|
| 234 |
+
}
|
| 235 |
+
|
| 236 |
+
function pauseGame() {
|
| 237 |
+
gamePaused = true;
|
| 238 |
+
pauseScreen.classList.remove('hidden');
|
| 239 |
+
road.classList.remove('animate-road');
|
| 240 |
+
clearInterval(gameLoop);
|
| 241 |
+
clearInterval(obstacleInterval);
|
| 242 |
+
}
|
| 243 |
+
|
| 244 |
+
function resumeGame() {
|
| 245 |
+
gamePaused = false;
|
| 246 |
+
pauseScreen.classList.add('hidden');
|
| 247 |
+
road.classList.add('animate-road');
|
| 248 |
+
gameLoop = setInterval(updateGame, 20);
|
| 249 |
+
obstacleInterval = setInterval(createObstacle, 1500);
|
| 250 |
+
}
|
| 251 |
+
|
| 252 |
+
function restartGame() {
|
| 253 |
+
pauseScreen.classList.add('hidden');
|
| 254 |
+
gameOverScreen.classList.add('hidden');
|
| 255 |
+
startGame();
|
| 256 |
+
}
|
| 257 |
+
|
| 258 |
+
function gameOver() {
|
| 259 |
+
gameActive = false;
|
| 260 |
+
gameOverScreen.classList.remove('hidden');
|
| 261 |
+
finalScoreElement.textContent = score;
|
| 262 |
+
road.classList.remove('animate-road');
|
| 263 |
+
|
| 264 |
+
// Update high score
|
| 265 |
+
if (score > highScore) {
|
| 266 |
+
highScore = score;
|
| 267 |
+
highscoreElement.textContent = highScore;
|
| 268 |
+
localStorage.setItem('akram2019car_highscore', highScore);
|
| 269 |
+
|
| 270 |
+
// Show new high score animation
|
| 271 |
+
const highScoreElement = document.createElement('div');
|
| 272 |
+
highScoreElement.className = 'absolute top-1/2 left-1/2 transform -translate-x-1/2 -translate-y-1/2 text-4xl font-bold text-yellow-400 score-pop';
|
| 273 |
+
highScoreElement.textContent = 'NEW HIGH SCORE!';
|
| 274 |
+
gameArea.appendChild(highScoreElement);
|
| 275 |
+
|
| 276 |
+
setTimeout(() => {
|
| 277 |
+
highScoreElement.remove();
|
| 278 |
+
}, 2000);
|
| 279 |
+
}
|
| 280 |
+
|
| 281 |
+
clearInterval(gameLoop);
|
| 282 |
+
clearInterval(obstacleInterval);
|
| 283 |
+
}
|
| 284 |
+
|
| 285 |
+
function updateGame() {
|
| 286 |
+
// Move obstacles
|
| 287 |
+
obstacles.forEach((obstacle, index) => {
|
| 288 |
+
const element = obstacle.element;
|
| 289 |
+
const top = parseInt(element.style.top) || 0;
|
| 290 |
+
const newTop = top + gameSpeed;
|
| 291 |
+
|
| 292 |
+
element.style.top = `${newTop}px`;
|
| 293 |
+
|
| 294 |
+
// Check collision
|
| 295 |
+
if (checkCollision(playerCar, element) && gameActive) {
|
| 296 |
+
gameOver();
|
| 297 |
+
}
|
| 298 |
+
|
| 299 |
+
// Remove obstacles that are out of screen
|
| 300 |
+
if (newTop > window.innerHeight) {
|
| 301 |
+
element.remove();
|
| 302 |
+
obstacles.splice(index, 1);
|
| 303 |
+
increaseScore();
|
| 304 |
+
}
|
| 305 |
+
});
|
| 306 |
+
|
| 307 |
+
// Increase difficulty
|
| 308 |
+
if (score > 0 && score % 10 === 0) {
|
| 309 |
+
gameSpeed = 5 + Math.floor(score / 10);
|
| 310 |
+
}
|
| 311 |
+
}
|
| 312 |
+
|
| 313 |
+
function createObstacle() {
|
| 314 |
+
if (!gameActive || gamePaused) return;
|
| 315 |
+
|
| 316 |
+
const positions = [0, 1, 2];
|
| 317 |
+
const randomPos = positions[Math.floor(Math.random() * positions.length)];
|
| 318 |
+
|
| 319 |
+
const obstacle = document.createElement('div');
|
| 320 |
+
obstacle.className = 'obstacle';
|
| 321 |
+
|
| 322 |
+
// Random obstacle type (car or box)
|
| 323 |
+
const obstacleType = Math.random() > 0.5 ? 'car' : 'box';
|
| 324 |
+
|
| 325 |
+
if (obstacleType === 'car') {
|
| 326 |
+
obstacle.className += ' w-16 h-28 bg-blue-600 rounded-lg';
|
| 327 |
+
obstacle.innerHTML = `
|
| 328 |
+
<div class="absolute top-0 left-1/2 transform -translate-x-1/2 w-12 h-4 bg-blue-700 rounded-t-sm"></div>
|
| 329 |
+
<div class="absolute bottom-0 left-1/2 transform -translate-x-1/2 w-14 h-6 bg-blue-800 rounded-b-lg"></div>
|
| 330 |
+
<div class="absolute top-1/4 left-0 w-4 h-8 bg-black bg-opacity-30 rounded-r-sm"></div>
|
| 331 |
+
<div class="absolute top-1/4 right-0 w-4 h-8 bg-black bg-opacity-30 rounded-l-sm"></div>
|
| 332 |
+
`;
|
| 333 |
+
} else {
|
| 334 |
+
obstacle.className += ' w-14 h-14 bg-gray-500 rounded-sm';
|
| 335 |
+
}
|
| 336 |
+
|
| 337 |
+
// Set initial position
|
| 338 |
+
let leftPosition;
|
| 339 |
+
if (randomPos === 0) {
|
| 340 |
+
leftPosition = '20%';
|
| 341 |
+
} else if (randomPos === 1) {
|
| 342 |
+
leftPosition = '50%';
|
| 343 |
+
} else {
|
| 344 |
+
leftPosition = '80%';
|
| 345 |
+
}
|
| 346 |
+
|
| 347 |
+
obstacle.style.left = leftPosition;
|
| 348 |
+
obstacle.style.top = '-100px';
|
| 349 |
+
|
| 350 |
+
gameArea.appendChild(obstacle);
|
| 351 |
+
obstacles.push({
|
| 352 |
+
element: obstacle,
|
| 353 |
+
position: randomPos
|
| 354 |
+
});
|
| 355 |
+
}
|
| 356 |
+
|
| 357 |
+
function moveLeft() {
|
| 358 |
+
if (playerPosition > 0) {
|
| 359 |
+
playerPosition--;
|
| 360 |
+
updatePlayerPosition();
|
| 361 |
+
}
|
| 362 |
+
}
|
| 363 |
+
|
| 364 |
+
function moveRight() {
|
| 365 |
+
if (playerPosition < 2) {
|
| 366 |
+
playerPosition++;
|
| 367 |
+
updatePlayerPosition();
|
| 368 |
+
}
|
| 369 |
+
}
|
| 370 |
+
|
| 371 |
+
function updatePlayerPosition() {
|
| 372 |
+
let leftPosition;
|
| 373 |
+
if (playerPosition === 0) {
|
| 374 |
+
leftPosition = '20%';
|
| 375 |
+
playerCar.style.transform = 'translateX(-50%) rotate(-10deg)';
|
| 376 |
+
} else if (playerPosition === 1) {
|
| 377 |
+
leftPosition = '50%';
|
| 378 |
+
playerCar.style.transform = 'translateX(-50%) rotate(0deg)';
|
| 379 |
+
} else {
|
| 380 |
+
leftPosition = '80%';
|
| 381 |
+
playerCar.style.transform = 'translateX(-50%) rotate(10deg)';
|
| 382 |
+
}
|
| 383 |
+
|
| 384 |
+
playerCar.style.left = leftPosition;
|
| 385 |
+
|
| 386 |
+
// Reset rotation after a short delay
|
| 387 |
+
setTimeout(() => {
|
| 388 |
+
if (playerPosition === 0) {
|
| 389 |
+
playerCar.style.transform = 'translateX(-50%) rotate(-5deg)';
|
| 390 |
+
} else if (playerPosition === 2) {
|
| 391 |
+
playerCar.style.transform = 'translateX(-50%) rotate(5deg)';
|
| 392 |
+
} else {
|
| 393 |
+
playerCar.style.transform = 'translateX(-50%) rotate(0deg)';
|
| 394 |
+
}
|
| 395 |
+
}, 100);
|
| 396 |
+
}
|
| 397 |
+
|
| 398 |
+
function increaseScore() {
|
| 399 |
+
score++;
|
| 400 |
+
scoreElement.textContent = score;
|
| 401 |
+
|
| 402 |
+
// Score pop effect
|
| 403 |
+
scoreElement.classList.add('score-pop');
|
| 404 |
+
setTimeout(() => {
|
| 405 |
+
scoreElement.classList.remove('score-pop');
|
| 406 |
+
}, 200);
|
| 407 |
+
}
|
| 408 |
+
|
| 409 |
+
function checkCollision(player, obstacle) {
|
| 410 |
+
const playerRect = player.getBoundingClientRect();
|
| 411 |
+
const obstacleRect = obstacle.getBoundingClientRect();
|
| 412 |
+
|
| 413 |
+
return !(
|
| 414 |
+
playerRect.top > obstacleRect.bottom ||
|
| 415 |
+
playerRect.right < obstacleRect.left ||
|
| 416 |
+
playerRect.bottom < obstacleRect.top ||
|
| 417 |
+
playerRect.left > obstacleRect.right
|
| 418 |
+
);
|
| 419 |
+
}
|
| 420 |
+
</script>
|
| 421 |
+
<p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-deepsite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - 🧬 <a href="https://enzostvs-deepsite.hf.space?remix=akram2019/https-cnetyjdg-manus-space" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
|
| 422 |
+
</html>
|