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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!DOCTYPE html>
|
| 2 |
+
<html lang="fa" dir="rtl">
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="UTF-8">
|
| 5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
+
<title>فضانورد شجاع - بازی تیراندازی فضایی</title>
|
| 7 |
+
<style>
|
| 8 |
+
* {
|
| 9 |
+
margin: 0;
|
| 10 |
+
padding: 0;
|
| 11 |
+
box-sizing: border-box;
|
| 12 |
+
}
|
| 13 |
+
|
| 14 |
+
body {
|
| 15 |
+
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
| 16 |
+
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
| 17 |
+
min-height: 100vh;
|
| 18 |
+
display: flex;
|
| 19 |
+
flex-direction: column;
|
| 20 |
+
align-items: center;
|
| 21 |
+
justify-content: center;
|
| 22 |
+
overflow: hidden;
|
| 23 |
+
position: relative;
|
| 24 |
+
}
|
| 25 |
+
|
| 26 |
+
body::before {
|
| 27 |
+
content: '';
|
| 28 |
+
position: absolute;
|
| 29 |
+
width: 200%;
|
| 30 |
+
height: 200%;
|
| 31 |
+
background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><circle cx="50" cy="50" r="1" fill="white" opacity="0.3"/></svg>');
|
| 32 |
+
background-size: 50px 50px;
|
| 33 |
+
animation: stars 120s linear infinite;
|
| 34 |
+
}
|
| 35 |
+
|
| 36 |
+
@keyframes stars {
|
| 37 |
+
from { transform: translate(0, 0); }
|
| 38 |
+
to { transform: translate(-50px, -50px); }
|
| 39 |
+
}
|
| 40 |
+
|
| 41 |
+
header {
|
| 42 |
+
position: absolute;
|
| 43 |
+
top: 20px;
|
| 44 |
+
width: 100%;
|
| 45 |
+
text-align: center;
|
| 46 |
+
z-index: 100;
|
| 47 |
+
}
|
| 48 |
+
|
| 49 |
+
.header-content {
|
| 50 |
+
display: flex;
|
| 51 |
+
justify-content: space-between;
|
| 52 |
+
align-items: center;
|
| 53 |
+
max-width: 1200px;
|
| 54 |
+
margin: 0 auto;
|
| 55 |
+
padding: 0 20px;
|
| 56 |
+
}
|
| 57 |
+
|
| 58 |
+
h1 {
|
| 59 |
+
color: white;
|
| 60 |
+
font-size: 2.5rem;
|
| 61 |
+
text-shadow: 0 0 20px rgba(255, 255, 255, 0.5);
|
| 62 |
+
animation: glow 2s ease-in-out infinite alternate;
|
| 63 |
+
}
|
| 64 |
+
|
| 65 |
+
@keyframes glow {
|
| 66 |
+
from { text-shadow: 0 0 20px rgba(255, 255, 255, 0.5); }
|
| 67 |
+
to { text-shadow: 0 0 30px rgba(255, 255, 255, 0.8), 0 0 40px rgba(255, 255, 255, 0.6); }
|
| 68 |
+
}
|
| 69 |
+
|
| 70 |
+
.built-with {
|
| 71 |
+
color: white;
|
| 72 |
+
font-size: 0.9rem;
|
| 73 |
+
opacity: 0.8;
|
| 74 |
+
text-decoration: none;
|
| 75 |
+
transition: opacity 0.3s;
|
| 76 |
+
}
|
| 77 |
+
|
| 78 |
+
.built-with:hover {
|
| 79 |
+
opacity: 1;
|
| 80 |
+
text-decoration: underline;
|
| 81 |
+
}
|
| 82 |
+
|
| 83 |
+
.game-container {
|
| 84 |
+
position: relative;
|
| 85 |
+
background: rgba(255, 255, 255, 0.1);
|
| 86 |
+
backdrop-filter: blur(10px);
|
| 87 |
+
border-radius: 20px;
|
| 88 |
+
padding: 20px;
|
| 89 |
+
box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
|
| 90 |
+
animation: fadeIn 1s ease-out;
|
| 91 |
+
}
|
| 92 |
+
|
| 93 |
+
@keyframes fadeIn {
|
| 94 |
+
from { opacity: 0; transform: scale(0.9); }
|
| 95 |
+
to { opacity: 1; transform: scale(1); }
|
| 96 |
+
}
|
| 97 |
+
|
| 98 |
+
canvas {
|
| 99 |
+
border: 2px solid rgba(255, 255, 255, 0.3);
|
| 100 |
+
border-radius: 10px;
|
| 101 |
+
display: block;
|
| 102 |
+
background: #000;
|
| 103 |
+
cursor: crosshair;
|
| 104 |
+
}
|
| 105 |
+
|
| 106 |
+
.game-stats {
|
| 107 |
+
display: flex;
|
| 108 |
+
justify-content: space-between;
|
| 109 |
+
margin-bottom: 15px;
|
| 110 |
+
padding: 15px;
|
| 111 |
+
background: rgba(255, 255, 255, 0.1);
|
| 112 |
+
border-radius: 10px;
|
| 113 |
+
color: white;
|
| 114 |
+
font-size: 1.1rem;
|
| 115 |
+
backdrop-filter: blur(5px);
|
| 116 |
+
}
|
| 117 |
+
|
| 118 |
+
.stat-item {
|
| 119 |
+
display: flex;
|
| 120 |
+
align-items: center;
|
| 121 |
+
gap: 10px;
|
| 122 |
+
}
|
| 123 |
+
|
| 124 |
+
.stat-icon {
|
| 125 |
+
font-size: 1.5rem;
|
| 126 |
+
}
|
| 127 |
+
|
| 128 |
+
.health-bar {
|
| 129 |
+
width: 150px;
|
| 130 |
+
height: 20px;
|
| 131 |
+
background: rgba(255, 255, 255, 0.2);
|
| 132 |
+
border-radius: 10px;
|
| 133 |
+
overflow: hidden;
|
| 134 |
+
position: relative;
|
| 135 |
+
}
|
| 136 |
+
|
| 137 |
+
.health-fill {
|
| 138 |
+
height: 100%;
|
| 139 |
+
background: linear-gradient(90deg, #ff6b6b, #ff3838);
|
| 140 |
+
transition: width 0.3s ease;
|
| 141 |
+
box-shadow: 0 0 10px rgba(255, 56, 56, 0.5);
|
| 142 |
+
}
|
| 143 |
+
|
| 144 |
+
.controls {
|
| 145 |
+
margin-top: 20px;
|
| 146 |
+
padding: 20px;
|
| 147 |
+
background: rgba(255, 255, 255, 0.1);
|
| 148 |
+
border-radius: 10px;
|
| 149 |
+
color: white;
|
| 150 |
+
text-align: center;
|
| 151 |
+
backdrop-filter: blur(5px);
|
| 152 |
+
}
|
| 153 |
+
|
| 154 |
+
.control-buttons {
|
| 155 |
+
display: flex;
|
| 156 |
+
gap: 15px;
|
| 157 |
+
justify-content: center;
|
| 158 |
+
margin-top: 15px;
|
| 159 |
+
}
|
| 160 |
+
|
| 161 |
+
button {
|
| 162 |
+
padding: 12px 30px;
|
| 163 |
+
font-size: 1rem;
|
| 164 |
+
font-weight: bold;
|
| 165 |
+
color: white;
|
| 166 |
+
background: linear-gradient(135deg, #667eea, #764ba2);
|
| 167 |
+
border: none;
|
| 168 |
+
border-radius: 50px;
|
| 169 |
+
cursor: pointer;
|
| 170 |
+
transition: all 0.3s ease;
|
| 171 |
+
box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
|
| 172 |
+
}
|
| 173 |
+
|
| 174 |
+
button:hover {
|
| 175 |
+
transform: translateY(-2px);
|
| 176 |
+
box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
|
| 177 |
+
}
|
| 178 |
+
|
| 179 |
+
button:active {
|
| 180 |
+
transform: translateY(0);
|
| 181 |
+
}
|
| 182 |
+
|
| 183 |
+
button:disabled {
|
| 184 |
+
opacity: 0.5;
|
| 185 |
+
cursor: not-allowed;
|
| 186 |
+
}
|
| 187 |
+
|
| 188 |
+
.mobile-controls {
|
| 189 |
+
display: none;
|
| 190 |
+
position: fixed;
|
| 191 |
+
bottom: 20px;
|
| 192 |
+
left: 50%;
|
| 193 |
+
transform: translateX(-50%);
|
| 194 |
+
gap: 20px;
|
| 195 |
+
z-index: 1000;
|
| 196 |
+
}
|
| 197 |
+
|
| 198 |
+
.mobile-btn {
|
| 199 |
+
width: 60px;
|
| 200 |
+
height: 60px;
|
| 201 |
+
border-radius: 50%;
|
| 202 |
+
background: rgba(255, 255, 255, 0.2);
|
| 203 |
+
backdrop-filter: blur(10px);
|
| 204 |
+
border: 2px solid rgba(255, 255, 255, 0.3);
|
| 205 |
+
color: white;
|
| 206 |
+
font-size: 1.5rem;
|
| 207 |
+
display: flex;
|
| 208 |
+
align-items: center;
|
| 209 |
+
justify-content: center;
|
| 210 |
+
cursor: pointer;
|
| 211 |
+
transition: all 0.2s;
|
| 212 |
+
}
|
| 213 |
+
|
| 214 |
+
.mobile-btn:active {
|
| 215 |
+
background: rgba(255, 255, 255, 0.4);
|
| 216 |
+
transform: scale(0.95);
|
| 217 |
+
}
|
| 218 |
+
|
| 219 |
+
@media (max-width: 768px) {
|
| 220 |
+
h1 { font-size: 1.8rem; }
|
| 221 |
+
.game-container { padding: 10px; }
|
| 222 |
+
.mobile-controls { display: flex; }
|
| 223 |
+
.controls { display: none; }
|
| 224 |
+
}
|
| 225 |
+
|
| 226 |
+
.power-up-indicator {
|
| 227 |
+
position: absolute;
|
| 228 |
+
top: 20px;
|
| 229 |
+
right: 20px;
|
| 230 |
+
padding: 10px 20px;
|
| 231 |
+
background: linear-gradient(135deg, #f093fb, #f5576c);
|
| 232 |
+
border-radius: 20px;
|
| 233 |
+
color: white;
|
| 234 |
+
font-weight: bold;
|
| 235 |
+
opacity: 0;
|
| 236 |
+
transition: opacity 0.3s;
|
| 237 |
+
z-index: 100;
|
| 238 |
+
}
|
| 239 |
+
|
| 240 |
+
.power-up-indicator.active {
|
| 241 |
+
opacity: 1;
|
| 242 |
+
animation: pulse 0.5s ease-in-out infinite;
|
| 243 |
+
}
|
| 244 |
+
|
| 245 |
+
@keyframes pulse {
|
| 246 |
+
0%, 100% { transform: scale(1); }
|
| 247 |
+
50% { transform: scale(1.05); }
|
| 248 |
+
}
|
| 249 |
+
|
| 250 |
+
.game-over-modal {
|
| 251 |
+
position: fixed;
|
| 252 |
+
top: 50%;
|
| 253 |
+
left: 50%;
|
| 254 |
+
transform: translate(-50%, -50%);
|
| 255 |
+
background: rgba(0, 0, 0, 0.9);
|
| 256 |
+
backdrop-filter: blur(10px);
|
| 257 |
+
padding: 40px;
|
| 258 |
+
border-radius: 20px;
|
| 259 |
+
color: white;
|
| 260 |
+
text-align: center;
|
| 261 |
+
z-index: 1000;
|
| 262 |
+
display: none;
|
| 263 |
+
}
|
| 264 |
+
|
| 265 |
+
.game-over-modal.active {
|
| 266 |
+
display: block;
|
| 267 |
+
animation: slideIn 0.5s ease-out;
|
| 268 |
+
}
|
| 269 |
+
|
| 270 |
+
@keyframes slideIn {
|
| 271 |
+
from {
|
| 272 |
+
opacity: 0;
|
| 273 |
+
transform: translate(-50%, -50%) scale(0.8);
|
| 274 |
+
}
|
| 275 |
+
to {
|
| 276 |
+
opacity: 1;
|
| 277 |
+
transform: translate(-50%, -50%) scale(1);
|
| 278 |
+
}
|
| 279 |
+
}
|
| 280 |
+
|
| 281 |
+
.game-over-modal h2 {
|
| 282 |
+
font-size: 2.5rem;
|
| 283 |
+
margin-bottom: 20px;
|
| 284 |
+
background: linear-gradient(135deg, #667eea, #764ba2);
|
| 285 |
+
-webkit-background-clip: text;
|
| 286 |
+
-webkit-text-fill-color: transparent;
|
| 287 |
+
}
|
| 288 |
+
|
| 289 |
+
.final-score {
|
| 290 |
+
font-size: 1.5rem;
|
| 291 |
+
margin-bottom: 30px;
|
| 292 |
+
}
|
| 293 |
+
|
| 294 |
+
.score-value {
|
| 295 |
+
color: #f5576c;
|
| 296 |
+
font-weight: bold;
|
| 297 |
+
}
|
| 298 |
+
</style>
|
| 299 |
+
</head>
|
| 300 |
+
<body>
|
| 301 |
+
<header>
|
| 302 |
+
<div class="header-content">
|
| 303 |
+
<div></div>
|
| 304 |
+
<h1>🚀 فضانورد شجاع</h1>
|
| 305 |
+
<a href="https://huggingface.co/spaces/akhaliq/anycoder" target="_blank" class="built-with">
|
| 306 |
+
Built with anycoder
|
| 307 |
+
</a>
|
| 308 |
+
</div>
|
| 309 |
+
</header>
|
| 310 |
+
|
| 311 |
+
<main class="game-container">
|
| 312 |
+
<div class="game-stats">
|
| 313 |
+
<div class="stat-item">
|
| 314 |
+
<span class="stat-icon">⭐</span>
|
| 315 |
+
<span>امتیاز: <span id="score">0</span></span>
|
| 316 |
+
</div>
|
| 317 |
+
<div class="stat-item">
|
| 318 |
+
<span class="stat-icon">❤️</span>
|
| 319 |
+
<div class="health-bar">
|
| 320 |
+
<div class="health-fill" id="healthBar" style="width: 100%"></div>
|
| 321 |
+
</div>
|
| 322 |
+
</div>
|
| 323 |
+
<div class="stat-item">
|
| 324 |
+
<span class="stat-icon">🎯</span>
|
| 325 |
+
<span>سطح: <span id="level">1</span></span>
|
| 326 |
+
</div>
|
| 327 |
+
</div>
|
| 328 |
+
|
| 329 |
+
<canvas id="gameCanvas"></canvas>
|
| 330 |
+
|
| 331 |
+
<div class="controls">
|
| 332 |
+
<p>🎮 استفاده از کلیدهای جهت��نما برای حرکت و کلید فضا برای شلیک</p>
|
| 333 |
+
<div class="control-buttons">
|
| 334 |
+
<button id="startBtn">شروع بازی</button>
|
| 335 |
+
<button id="pauseBtn" disabled>توقف</button>
|
| 336 |
+
<button id="restartBtn" disabled="true">راهاندازی مجدد</button>
|
| 337 |
+
</div>
|
| 338 |
+
</div>
|
| 339 |
+
</main>
|
| 340 |
+
|
| 341 |
+
<div class="mobile-controls">
|
| 342 |
+
<div class="mobile-btn" id="leftBtn">⬅️</div>
|
| 343 |
+
<div class="mobile-btn" id="fireBtn">🔥</div>
|
| 344 |
+
<div class="mobile-btn" id="rightBtn">➡️</div>
|
| 345 |
+
</div>
|
| 346 |
+
|
| 347 |
+
<div class="power-up-indicator" id="powerUpIndicator">
|
| 348 |
+
⚡ قدرت ویژه فعال!
|
| 349 |
+
</div>
|
| 350 |
+
|
| 351 |
+
<div class="game-over-modal" id="gameOverModal">
|
| 352 |
+
<h2>🎮 بازی تمام شد!</h2>
|
| 353 |
+
<div class="final-score">
|
| 354 |
+
امتیاز نهایی: <span class="score-value" id="finalScore">0</span>
|
| 355 |
+
</div>
|
| 356 |
+
<button onclick="restartGame()">بازی دوباره</button>
|
| 357 |
+
</div>
|
| 358 |
+
|
| 359 |
+
<script>
|
| 360 |
+
const canvas = document.getElementById('gameCanvas');
|
| 361 |
+
const ctx = canvas.getContext('2d');
|
| 362 |
+
|
| 363 |
+
// تنظیم اندازه کانواس
|
| 364 |
+
canvas.width = 800;
|
| 365 |
+
canvas.height = 600;
|
| 366 |
+
|
| 367 |
+
// متغیرهای بازی
|
| 368 |
+
let gameRunning = false;
|
| 369 |
+
let gamePaused = false;
|
| 370 |
+
let score = 0;
|
| 371 |
+
let level = 1;
|
| 372 |
+
let health = 100;
|
| 373 |
+
let powerUpActive = false;
|
| 374 |
+
let powerUpTimer = 0;
|
| 375 |
+
|
| 376 |
+
// بازیکن
|
| 377 |
+
const player = {
|
| 378 |
+
x: canvas.width / 2,
|
| 379 |
+
y: canvas.height - 80,
|
| 380 |
+
width: 50,
|
| 381 |
+
height: 50,
|
| 382 |
+
speed: 7,
|
| 383 |
+
color: '#00ff88'
|
| 384 |
+
};
|
| 385 |
+
|
| 386 |
+
// گلولهها
|
| 387 |
+
let bullets = [];
|
| 388 |
+
let enemyBullets = [];
|
| 389 |
+
|
| 390 |
+
// دشمنان
|
| 391 |
+
let enemies = [];
|
| 392 |
+
let enemySpawnTimer = 0;
|
| 393 |
+
let enemySpawnRate = 60;
|
| 394 |
+
|
| 395 |
+
// ذرات برای انفجار
|
| 396 |
+
let particles = [];
|
| 397 |
+
|
| 398 |
+
// قدرتها
|
| 399 |
+
let powerUps = [];
|
| 400 |
+
|
| 401 |
+
// ستارههای پسزمینه
|
| 402 |
+
let stars = [];
|
| 403 |
+
for (let i = 0; i < 100; i++) {
|
| 404 |
+
stars.push({
|
| 405 |
+
x: Math.random() * canvas.width,
|
| 406 |
+
y: Math.random() * canvas.height,
|
| 407 |
+
size: Math.random() * 2,
|
| 408 |
+
speed: Math.random() * 2 + 0.5
|
| 409 |
+
});
|
| 410 |
+
}
|
| 411 |
+
|
| 412 |
+
// کنترلها
|
| 413 |
+
const keys = {};
|
| 414 |
+
|
| 415 |
+
document.addEventListener('keydown', (e) => {
|
| 416 |
+
keys[e.key] = true;
|
| 417 |
+
if (e.key === ' ') {
|
| 418 |
+
e.preventDefault();
|
| 419 |
+
shoot();
|
| 420 |
+
}
|
| 421 |
+
});
|
| 422 |
+
|
| 423 |
+
document.addEventListener('keyup', (e) => {
|
| 424 |
+
keys[e.key] = false;
|
| 425 |
+
});
|
| 426 |
+
|
| 427 |
+
// کنترلهای موبایل
|
| 428 |
+
let mobileLeft = false;
|
| 429 |
+
let mobileRight = false;
|
| 430 |
+
|
| 431 |
+
document.getElementById('leftBtn').addEventListener('touchstart', () => mobileLeft = true);
|
| 432 |
+
document.getElementById('leftBtn').addEventListener('touchend', () => mobileLeft = false);
|
| 433 |
+
document.getElementById('rightBtn').addEventListener('touchstart', () => mobileRight = true);
|
| 434 |
+
document.getElementById('rightBtn').addEventListener('touchend', () => mobileRight = false);
|
| 435 |
+
document.getElementById('fireBtn').addEventListener('touchstart', shoot);
|
| 436 |
+
|
| 437 |
+
// توابع بازی
|
| 438 |
+
function shoot() {
|
| 439 |
+
if (!gameRunning || gamePaused) return;
|
| 440 |
+
|
| 441 |
+
if (powerUpActive) {
|
| 442 |
+
// شلیک سهگانه
|
| 443 |
+
bullets.push(
|
| 444 |
+
{ x: player.x - 15, y: player.y, speed: 10, width: 4, height: 10 },
|
| 445 |
+
{ x: player.x, y: player.y, speed: 10, width: 4, height: 10 },
|
| 446 |
+
{ x: player.x + 15, y: player.y, speed: 10, width: 4, height: 10 }
|
| 447 |
+
);
|
| 448 |
+
} else {
|
| 449 |
+
bullets.push({
|
| 450 |
+
x: player.x,
|
| 451 |
+
y: player.y,
|
| 452 |
+
speed: 10,
|
| 453 |
+
width: 4,
|
| 454 |
+
height: 10
|
| 455 |
+
});
|
| 456 |
+
}
|
| 457 |
+
}
|
| 458 |
+
|
| 459 |
+
function spawnEnemy() {
|
| 460 |
+
const types = ['basic', 'fast', 'heavy'];
|
| 461 |
+
const type = types[Math.floor(Math.random() * Math.min(types.length, level))];
|
| 462 |
+
|
| 463 |
+
const enemy = {
|
| 464 |
+
x: Math.random() * (canvas.width - 40) + 20,
|
| 465 |
+
y: -40,
|
| 466 |
+
width: 40,
|
| 467 |
+
height: 40,
|
| 468 |
+
speed: type === 'fast' ? 3 : type === 'heavy' ? 1 : 2,
|
| 469 |
+
health: type === 'heavy' ? 3 : 1,
|
| 470 |
+
type: type,
|
| 471 |
+
shootTimer: 0,
|
| 472 |
+
shootRate: type === 'heavy' ? 30 : 60
|
| 473 |
+
};
|
| 474 |
+
|
| 475 |
+
enemies.push(enemy);
|
| 476 |
+
}
|
| 477 |
+
|
| 478 |
+
function spawnPowerUp() {
|
| 479 |
+
if (Math.random() < 0.01) {
|
| 480 |
+
powerUps.push({
|
| 481 |
+
x: Math.random() * (canvas.width - 30) + 15,
|
| 482 |
+
y: -30,
|
| 483 |
+
width: 30,
|
| 484 |
+
height: 30,
|
| 485 |
+
speed: 2,
|
| 486 |
+
type: Math.random() < 0.5 ? 'triple' : 'health'
|
| 487 |
+
});
|
| 488 |
+
}
|
| 489 |
+
}
|
| 490 |
+
|
| 491 |
+
function createExplosion(x, y) {
|
| 492 |
+
for (let i = 0; i < 20; i++) {
|
| 493 |
+
particles.push({
|
| 494 |
+
x: x,
|
| 495 |
+
y: y,
|
| 496 |
+
vx: (Math.random() - 0.5) * 8,
|
| 497 |
+
vy: (Math.random() - 0.5) * 8,
|
| 498 |
+
size: Math.random() * 5 + 2,
|
| 499 |
+
life: 30,
|
| 500 |
+
color: `hsl(${Math.random() * 60}, 100%, 50%)`
|
| 501 |
+
});
|
| 502 |
+
}
|
| 503 |
+
}
|
| 504 |
+
|
| 505 |
+
function updatePlayer() {
|
| 506 |
+
if (keys['ArrowLeft'] || mobileLeft) {
|
| 507 |
+
player.x = Math.max(player.width / 2, player.x - player.speed);
|
| 508 |
+
}
|
| 509 |
+
if (keys['ArrowRight'] || mobileRight) {
|
| 510 |
+
player.x = Math.min(canvas.width - player.width / 2, player.x + player.speed);
|
| 511 |
+
}
|
| 512 |
+
}
|
| 513 |
+
|
| 514 |
+
function updateBullets() {
|
| 515 |
+
bullets = bullets.filter(bullet => {
|
| 516 |
+
bullet.y -= bullet.speed;
|
| 517 |
+
return bullet.y > -10;
|
| 518 |
+
});
|
| 519 |
+
|
| 520 |
+
enemyBullets = enemyBullets.filter(bullet => {
|
| 521 |
+
bullet.y += bullet.speed;
|
| 522 |
+
return bullet.y < canvas.height + 10;
|
| 523 |
+
});
|
| 524 |
+
}
|
| 525 |
+
|
| 526 |
+
function updateEnemies() {
|
| 527 |
+
enemies = enemies.filter(enemy => {
|
| 528 |
+
enemy.y += enemy.speed;
|
| 529 |
+
|
| 530 |
+
// شلیک دشمن
|
| 531 |
+
enemy.shootTimer++;
|
| 532 |
+
if (enemy.shootTimer >= enemy.shootRate) {
|
| 533 |
+
enemyBullets.push({
|
| 534 |
+
x: enemy.x,
|
| 535 |
+
y: enemy.y + enemy.height / 2,
|
| 536 |
+
speed: 4,
|
| 537 |
+
width: 4,
|
| 538 |
+
height: 8
|
| 539 |
+
});
|
| 540 |
+
enemy.shootTimer = 0;
|
| 541 |
+
}
|
| 542 |
+
|
| 543 |
+
return enemy.y < canvas.height + 50 && enemy.health > 0;
|
| 544 |
+
});
|
| 545 |
+
}
|
| 546 |
+
|
| 547 |
+
function updateParticles() {
|
| 548 |
+
particles = particles.filter(particle => {
|
| 549 |
+
particle.x += particle.vx;
|
| 550 |
+
particle.y += particle.vy;
|
| 551 |
+
particle.vx *= 0.98;
|
| 552 |
+
particle.vy *= 0.98;
|
| 553 |
+
particle.life--;
|
| 554 |
+
particle.size *= 0.98;
|
| 555 |
+
return particle.life > 0;
|
| 556 |
+
});
|
| 557 |
+
}
|
| 558 |
+
|
| 559 |
+
function updatePowerUps() {
|
| 560 |
+
powerUps = powerUps.filter(powerUp => {
|
| 561 |
+
powerUp.y += powerUp.speed;
|
| 562 |
+
return powerUp.y < canvas.height + 30;
|
| 563 |
+
});
|
| 564 |
+
}
|
| 565 |
+
|
| 566 |
+
function updateStars() {
|
| 567 |
+
stars.forEach(star => {
|
| 568 |
+
star.y += star.speed;
|
| 569 |
+
if (star.y > canvas.height) {
|
| 570 |
+
star.y = 0;
|
| 571 |
+
star.x = Math.random() * canvas.width;
|
| 572 |
+
}
|
| 573 |
+
});
|
| 574 |
+
}
|
| 575 |
+
|
| 576 |
+
function checkCollisions() {
|
| 577 |
+
// برخورد گلوله با دشمن
|
| 578 |
+
bullets.forEach((bullet, bulletIndex) => {
|
| 579 |
+
enemies.forEach((enemy, enemyIndex) => {
|
| 580 |
+
if (bullet.x > enemy.x - enemy.width / 2 &&
|
| 581 |
+
bullet.x < enemy.x + enemy.width / 2 &&
|
| 582 |
+
bullet.y > enemy.y - enemy.height / 2 &&
|
| 583 |
+
bullet.y < enemy.y + enemy.height / 2) {
|
| 584 |
+
|
| 585 |
+
enemy.health--;
|
| 586 |
+
bullets.splice(bulletIndex, 1);
|
| 587 |
+
|
| 588 |
+
if (enemy.health <= 0) {
|
| 589 |
+
createExplosion(enemy.x, enemy.y);
|
| 590 |
+
enemies.splice(enemyIndex, 1);
|
| 591 |
+
score += enemy.type === 'heavy' ? 30 : enemy.type === 'fast' ? 20 : 10;
|
| 592 |
+
updateScore();
|
| 593 |
+
}
|
| 594 |
+
}
|
| 595 |
+
});
|
| 596 |
+
});
|
| 597 |
+
|
| 598 |
+
// برخورد گلوله دشمن با بازیکن
|
| 599 |
+
enemyBullets.forEach((bullet, index) => {
|
| 600 |
+
if (bullet.x > player.x - player.width / 2 &&
|
| 601 |
+
bullet.x < player.x + player.width / 2 &&
|
| 602 |
+
bullet.y > player.y - player.height / 2 &&
|
| 603 |
+
bullet.y < player.y + player.height / 2) {
|
| 604 |
+
|
| 605 |
+
enemyBullets.splice(index, 1);
|
| 606 |
+
takeDamage(10);
|
| 607 |
+
}
|
| 608 |
+
});
|
| 609 |
+
|
| 610 |
+
// برخورد دشمن با بازیکن
|
| 611 |
+
enemies.forEach((enemy, index) => {
|
| 612 |
+
if (Math.abs(enemy.x - player.x) < (enemy.width + player.width) / 2 &&
|
| 613 |
+
Math.abs(enemy.y - player.y) < (enemy.height + player.height) / 2) {
|
| 614 |
+
|
| 615 |
+
createExplosion(enemy.x, enemy.y);
|
| 616 |
+
enemies.splice(index, 1);
|
| 617 |
+
takeDamage(20);
|
| 618 |
+
}
|
| 619 |
+
});
|
| 620 |
+
|
| 621 |
+
// برخورد قدرت با بازیکن
|
| 622 |
+
powerUps.forEach((powerUp, index) => {
|
| 623 |
+
if (Math.abs(powerUp.x - player.x) < (powerUp.width + player.width) / 2 &&
|
| 624 |
+
Math.abs(powerUp.y - player.y) < (powerUp.height + player.height) / 2) {
|
| 625 |
+
|
| 626 |
+
if (powerUp.type === 'triple') {
|
| 627 |
+
activatePowerUp();
|
| 628 |
+
} else if (powerUp.type === 'health') {
|
| 629 |
+
health = Math.min(100, health + 30);
|
| 630 |
+
updateHealth();
|
| 631 |
+
}
|
| 632 |
+
|
| 633 |
+
powerUps.splice(index, 1);
|
| 634 |
+
}
|
| 635 |
+
});
|
| 636 |
+
}
|
| 637 |
+
|
| 638 |
+
function takeDamage(amount) {
|
| 639 |
+
health -= amount;
|
| 640 |
+
updateHealth();
|
| 641 |
+
|
| 642 |
+
if (health <= 0) {
|
| 643 |
+
gameOver();
|
| 644 |
+
}
|
| 645 |
+
}
|
| 646 |
+
|
| 647 |
+
function activatePowerUp() {
|
| 648 |
+
powerUpActive = true;
|
| 649 |
+
powerUpTimer = 300; // 5 ثانیه در 60 فریم
|
| 650 |
+
document.getElementById('powerUpIndicator').classList.add('active');
|
| 651 |
+
}
|
| 652 |
+
|
| 653 |
+
function updateScore() {
|
| 654 |
+
document.getElementById('score').textContent = score;
|
| 655 |
+
|
| 656 |
+
// افزایش سطح
|
| 657 |
+
const newLevel = Math.floor(score / 100) + 1;
|
| 658 |
+
if (newLevel > level) {
|
| 659 |
+
level = newLevel;
|
| 660 |
+
document.getElementById('level').textContent = level;
|
| 661 |
+
enemySpawnRate = Math.max(30, 60 - level * 5);
|
| 662 |
+
}
|
| 663 |
+
}
|
| 664 |
+
|
| 665 |
+
function updateHealth() {
|
| 666 |
+
document.getElementById('healthBar').style.width = health + '%';
|
| 667 |
+
}
|
| 668 |
+
|
| 669 |
+
function drawPlayer() {
|
| 670 |
+
ctx.save();
|
| 671 |
+
ctx.translate(player.x, player.y);
|
| 672 |
+
|
| 673 |
+
// بدنه سفینه
|
| 674 |
+
ctx.fillStyle = player.color;
|
| 675 |
+
ctx.beginPath();
|
| 676 |
+
ctx.moveTo(0, -25);
|
| 677 |
+
ctx.lineTo(-20, 20);
|
| 678 |
+
ctx.lineTo(0, 10);
|
| 679 |
+
ctx.lineTo(20, 20);
|
| 680 |
+
ctx.closePath();
|
| 681 |
+
ctx.fill();
|
| 682 |
+
|
| 683 |
+
// بالهها
|
| 684 |
+
ctx.fillStyle = '#00ffcc';
|
| 685 |
+
ctx.beginPath();
|
| 686 |
+
ctx.moveTo(-20, 10);
|
| 687 |
+
ctx.lineTo(-30, 25);
|
| 688 |
+
ctx.lineTo(-15, 20);
|
| 689 |
+
ctx.closePath();
|
| 690 |
+
ctx.fill();
|
| 691 |
+
|
| 692 |
+
ctx.beginPath();
|
| 693 |
+
ctx.moveTo(20, 10);
|
| 694 |
+
ctx.lineTo(30, 25);
|
| 695 |
+
ctx.lineTo(15, 20);
|
| 696 |
+
ctx.closePath();
|
| 697 |
+
ctx.fill();
|
| 698 |
+
|
| 699 |
+
// موتور
|
| 700 |
+
if (Math.random() > 0.3) {
|
| 701 |
+
ctx.fillStyle = '#ff6600';
|
| 702 |
+
ctx.beginPath();
|
| 703 |
+
ctx.ellipse(-10, 25, 5, 10, 0, 0, Math.PI * 2);
|
| 704 |
+
ctx.fill();
|
| 705 |
+
ctx.beginPath();
|
| 706 |
+
ctx.ellipse(10, 25, 5, 10, 0, 0, Math.PI * 2);
|
| 707 |
+
ctx.fill();
|
| 708 |
+
}
|
| 709 |
+
|
| 710 |
+
ctx.restore();
|
| 711 |
+
}
|
| 712 |
+
|
| 713 |
+
function drawEnemies() {
|
| 714 |
+
enemies.forEach(enemy => {
|
| 715 |
+
ctx.save();
|
| 716 |
+
ctx.translate(enemy.x, enemy.y);
|
| 717 |
+
|
| 718 |
+
const color = enemy.type === 'heavy' ? '#ff3366' :
|
| 719 |
+
enemy.type === 'fast' ? '#ff9933' : '#ff0066';
|
| 720 |
+
|
| 721 |
+
ctx.fillStyle = color;
|
| 722 |
+
ctx.beginPath();
|
| 723 |
+
ctx.moveTo(0, 20);
|
| 724 |
+
ctx.lineTo(-20, -15);
|
| 725 |
+
ctx.lineTo(0, -20);
|
| 726 |
+
ctx.lineTo(20, -15);
|
| 727 |
+
ctx.closePath();
|
| 728 |
+
ctx.fill();
|
| 729 |
+
|
| 730 |
+
// جزئیات
|
| 731 |
+
ctx.fillStyle = 'rgba(0, 0, 0, 0.3)';
|
| 732 |
+
ctx.beginPath();
|
| 733 |
+
ctx.arc(0, -5, 8, 0, Math.PI * 2);
|
| 734 |
+
ctx.fill();
|
| 735 |
+
|
| 736 |
+
ctx.restore();
|
| 737 |
+
});
|
| 738 |
+
}
|
| 739 |
+
|
| 740 |
+
function drawBullets() {
|
| 741 |
+
// گلولههای بازیکن
|
| 742 |
+
ctx.fillStyle = '#00ffff';
|
| 743 |
+
ctx.shadowBlur = 10;
|
| 744 |
+
ctx.shadowColor = '#00ffff';
|
| 745 |
+
bullets.forEach(bullet => {
|
| 746 |
+
ctx.fillRect(bullet.x - bullet.width / 2, bullet.y, bullet.width, bullet.height);
|
| 747 |
+
});
|
| 748 |
+
|
| 749 |
+
// گلولههای دشمن
|
| 750 |
+
ctx.fillStyle = '#ff3366';
|
| 751 |
+
ctx.shadowColor = '#ff3366';
|
| 752 |
+
enemyBullets.forEach(bullet => {
|
| 753 |
+
ctx.fillRect(bullet.x - bullet.width / 2, bullet.y, bullet.width, bullet.height);
|
| 754 |
+
});
|
| 755 |
+
|
| 756 |
+
ctx.shadowBlur = 0;
|
| 757 |
+
}
|
| 758 |
+
|
| 759 |
+
function drawParticles() {
|
| 760 |
+
particles.forEach(particle => {
|
| 761 |
+
ctx.globalAlpha = particle.life / 30;
|
| 762 |
+
ctx.fillStyle = particle.color;
|
| 763 |
+
ctx.beginPath();
|
| 764 |
+
ctx.arc(particle.x, particle.y, particle.size, 0, Math.PI * 2);
|
| 765 |
+
ctx.fill();
|
| 766 |
+
});
|
| 767 |
+
ctx.globalAlpha = 1;
|
| 768 |
+
}
|
| 769 |
+
|
| 770 |
+
function drawPowerUps() {
|
| 771 |
+
powerUps.forEach(powerUp => {
|
| 772 |
+
ctx.save();
|
| 773 |
+
ctx.translate(powerUp.x, powerUp.y);
|
| 774 |
+
ctx.rotate(Date.now() * 0.002);
|
| 775 |
+
|
| 776 |
+
if (powerUp.type === 'triple') {
|
| 777 |
+
ctx.fillStyle = '#ffff00';
|
| 778 |
+
ctx.shadowBlur = 20;
|
| 779 |
+
ctx.shadowColor = '#ffff00';
|
| 780 |
+
ctx.font = '20px Arial';
|
| 781 |
+
ctx.textAlign = 'center';
|
| 782 |
+
ctx.fillText('⚡', 0, 5);
|
| 783 |
+
} else {
|
| 784 |
+
ctx.fillStyle = '#00ff00';
|
| 785 |
+
ctx.shadowBlur = 20;
|
| 786 |
+
ctx.shadowColor = '#00ff00';
|
| 787 |
+
ctx.font = '20px Arial';
|
| 788 |
+
ctx.textAlign = 'center';
|
| 789 |
+
ctx.fillText('❤️', 0, 5);
|
| 790 |
+
}
|
| 791 |
+
|
| 792 |
+
ctx.restore();
|
| 793 |
+
});
|
| 794 |
+
ctx.shadowBlur = 0;
|
| 795 |
+
}
|
| 796 |
+
|
| 797 |
+
function drawStars() {
|
| 798 |
+
ctx.fillStyle = 'white';
|
| 799 |
+
stars.forEach(star => {
|
| 800 |
+
ctx.globalAlpha = star.size / 2;
|
| 801 |
+
ctx.fillRect(star.x, star.y, star.size, star.size);
|
| 802 |
+
});
|
| 803 |
+
ctx.globalAlpha = 1;
|
| 804 |
+
}
|
| 805 |
+
|
| 806 |
+
function gameLoop() {
|
| 807 |
+
if (!gameRunning || gamePaused) return;
|
| 808 |
+
|
| 809 |
+
// پاک کردن کانواس
|
| 810 |
+
ctx.fillStyle = 'rgba(0, 0, 0, 0.9)';
|
| 811 |
+
ctx.fillRect(0, 0, canvas.width, canvas.height);
|
| 812 |
+
|
| 813 |
+
// بهروزرسانی
|
| 814 |
+
updateStars();
|
| 815 |
+
updatePlayer();
|
| 816 |
+
updateBullets();
|
| 817 |
+
updateEnemies();
|
| 818 |
+
updateParticles();
|
| 819 |
+
updatePowerUps();
|
| 820 |
+
checkCollisions();
|
| 821 |
+
|
| 822 |
+
// اسپاون دشمن
|
| 823 |
+
enemySpawnTimer++;
|
| 824 |
+
if (enemySpawnTimer >= enemySpawnRate) {
|
| 825 |
+
spawnEnemy();
|
| 826 |
+
enemySpawnTimer = 0;
|
| 827 |
+
}
|
| 828 |
+
|
| 829 |
+
spawnPowerUp();
|
| 830 |
+
|
| 831 |
+
// بهروزرسانی قدرت ویژه
|
| 832 |
+
if (powerUpActive) {
|
| 833 |
+
powerUpTimer--;
|
| 834 |
+
if (powerUpTimer <= 0) {
|
| 835 |
+
powerUpActive = false;
|
| 836 |
+
document.getElementById('powerUpIndicator').classList.remove('active');
|
| 837 |
+
}
|
| 838 |
+
}
|
| 839 |
+
|
| 840 |
+
// رسم
|
| 841 |
+
drawStars();
|
| 842 |
+
drawParticles();
|
| 843 |
+
drawPowerUps();
|
| 844 |
+
drawBullets();
|
| 845 |
+
drawEnemies();
|
| 846 |
+
drawPlayer();
|
| 847 |
+
|
| 848 |
+
requestAnimationFrame(gameLoop);
|
| 849 |
+
}
|
| 850 |
+
|
| 851 |
+
function startGame() {
|
| 852 |
+
gameRunning = true;
|
| 853 |
+
gamePaused = false;
|
| 854 |
+
score = 0;
|
| 855 |
+
level = 1;
|
| 856 |
+
health = 100;
|
| 857 |
+
bullets = [];
|
| 858 |
+
enemyBullets = [];
|
| 859 |
+
enemies = [];
|
| 860 |
+
particles = [];
|
| 861 |
+
powerUps = [];
|
| 862 |
+
powerUpActive = false;
|
| 863 |
+
|
| 864 |
+
updateScore();
|
| 865 |
+
updateHealth();
|
| 866 |
+
|
| 867 |
+
document.getElementById('startBtn').disabled = true;
|
| 868 |
+
document.getElementById('pauseBtn').disabled = false;
|
| 869 |
+
document.getElementById('restartBtn').disabled = false;
|
| 870 |
+
|
| 871 |
+
gameLoop();
|
| 872 |
+
}
|
| 873 |
+
|
| 874 |
+
function pauseGame() {
|
| 875 |
+
gamePaused = !gamePaused;
|
| 876 |
+
document.getElementById('pauseBtn').textContent = gamePaused ? 'ادامه' : 'توقف';
|
| 877 |
+
if (!gamePaused) gameLoop();
|
| 878 |
+
}
|
| 879 |
+
|
| 880 |
+
function restartGame() {
|
| 881 |
+
document.getElementById('gameOverModal').classList.remove('active');
|
| 882 |
+
startGame();
|
| 883 |
+
}
|
| 884 |
+
|
| 885 |
+
function gameOver() {
|
| 886 |
+
gameRunning = false;
|
| 887 |
+
document.getElementById('finalScore').textContent = score;
|
| 888 |
+
document.getElementById('gameOverModal').classList.add('active');
|
| 889 |
+
document.getElementById('startBtn').disabled = false;
|
| 890 |
+
document.getElementById('pauseBtn').disabled = true;
|
| 891 |
+
}
|
| 892 |
+
|
| 893 |
+
// دکمهها
|
| 894 |
+
document.getElementById('startBtn').addEventListener('click', startGame);
|
| 895 |
+
document.getElementById('pauseBtn').addEventListener('click', pauseGame);
|
| 896 |
+
document.getElementById('restartBtn').addEventListener('click', restartGame);
|
| 897 |
+
|
| 898 |
+
// رسم اولیه
|
| 899 |
+
ctx.fillStyle = 'black';
|
| 900 |
+
ctx.fillRect(0, 0, canvas.width, canvas.height);
|
| 901 |
+
drawStars();
|
| 902 |
+
|
| 903 |
+
// متن شروع
|
| 904 |
+
ctx.fillStyle = 'white';
|
| 905 |
+
ctx.font = 'bold 30px Arial';
|
| 906 |
+
ctx.textAlign = 'center';
|
| 907 |
+
ctx.fillText('برای شروع روی دکمه "شروع بازی" کلیک کنید', canvas.width / 2, canvas.height / 2);
|
| 908 |
+
</script>
|
| 909 |
+
</body>
|
| 910 |
+
</html>
|