🎮ArcadeLab

لعبة طخ الأشباح - 20 سلاح

by ChromeFlame24
460 lines20.5 KB
▶ Play
<!DOCTYPE html>
<html lang="ar" dir="rtl">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>لعبة طخ الأشباح - 20 سلاح</title>
<style>
  *{box-sizing:border-box; font-family:Tahoma, Arial, sans-serif;}
  body{margin:0; background:#0a0a12; color:#fff; overflow-x:hidden;}
  .top{padding:12px; display:flex; justify-content:space-between; align-items:center; background:#1a1a2e; border-bottom:2px solid #a855f7; flex-wrap:wrap; gap:10px;}
  .top h1{margin:0; font-size:20px; color:#c084fc;}
  .stats{display:flex; gap:14px; font-weight:bold; font-size:15px; flex-wrap:wrap;}
  .stats span{color:#facc15;}
  #hpBar{width:120px; height:12px; background:#333; border-radius:20px; overflow:hidden; display:inline-block; vertical-align:middle;}
  #hpFill{height:100%; background:#ef4444; width:100%; transition:0.3s;}
  #gameWrap{position:relative; max-width:950px; margin:15px auto; padding:0 10px;}
  canvas{width:100%; height:540px; background:#0b0b1a; border:3px solid #a855f7; border-radius:12px; cursor:crosshair; display:block;}
  #flash{position:absolute; top:60%; left:50%; width:90px; height:90px; background:radial-gradient(circle, #fff 0%, #facc15 30%, #f97316 60%, transparent 70%); border-radius:50%; pointer-events:none; opacity:0; transform:translate(-50%,-50%); mix-blend-mode:screen; z-index:5;}
  #weapons{display:grid; grid-template-columns:repeat(auto-fill,minmax(135px,1fr)); gap:8px; max-width:950px; margin:0 auto 15px; padding:0 10px;}
  .wbtn{background:#1e1e30; border:2px solid #444; color:#fff; padding:10px 8px; border-radius:10px; cursor:pointer; text-align:center; transition:0.15s;}
  .wbtn small{display:block; color:#aaa; font-size:11px; margin-top:4px;}
  .wbtn.active{background:#a855f7; color:#fff; border-color:#a855f7; transform:scale(1.03);}
  .wbtn.active small{color:#eee;}
  .hint{text-align:center; color:#ccc; font-size:13px; padding-bottom:20px;}
  .hint b{color:#facc15;}
  #gameOver{position:absolute; top:50%; left:50%; transform:translate(-50%,-50%); background:rgba(0,0,0,0.9); padding:25px 35px; border-radius:15px; text-align:center; border:2px solid #ef4444; display:none; z-index:10;}
  #gameOver button{background:#ef4444; color:#fff; border:none; padding:12px 25px; border-radius:10px; font-size:16px; cursor:pointer; margin-top:10px;}
</style>
</head>
<body>

<div class="top">
  <h1>👻 لعبة طخ الأشباح - 20 سلاح</h1>
  <div class="stats">
    <div>السلاح: <span id="curName">AK-47</span></div>
    <div>الطلقات: <span id="ammo">30 / 30</span></div>
    <div>النقاط: <span id="score">0</span></div>
    <div>قتلى: <span id="kills">0</span></div>
    <div>صحتك: <span id="hpBar"><span id="hpFill"></span></span> <span id="hpText">100</span></div>
  </div>
</div>

<div id="gameWrap">
  <canvas id="c" width="920" height="540"></canvas>
  <div id="flash"></div>
  <div id="gameOver">
    <h2 style="color:#ef4444; margin:0;">💀 خسرت! الأشباح غلبوك</h2>
    <p id="finalScore" style="font-size:18px;"></p>
    <button onclick="restart()">العب مرة ثانية</button>
  </div>
</div>

<div id="weapons"></div>
<p class="hint">الأشباح بتبين وبتطير عليك، طخها قبل ما توصلك • <b>R</b> للتلقيم • <b>1 - 0</b> لتبديل السلاح • الشبح الكبير بده أكثر من طلقة</p>

<script>
const canvas = document.getElementById('c');
const ctx = canvas.getContext('2d');
const flashEl = document.getElementById('flash');

// 20 سلاح حقيقي
const weapons = [
  { name:"AK-47", damage:34, fireRate:120, mag:30, reload:2200, type:"rifle", power:1.0, desc:"رشاش روسي - قوي وثابت" },
  { name:"M4A1", damage:30, fireRate:110, mag:30, reload:2000, type:"rifle", power:0.9, desc:"رشاش أمريكي سريع" },
  { name:"M16A4", damage:32, fireRate:140, mag:30, reload:2100, type:"rifle", power:0.95, desc:"بندقية هجومية دقيقة" },
  { name:"SCAR-L", damage:36, fireRate:130, mag:30, reload:2300, type:"rifle", power:1.05, desc:"بلجيكي - ضرر عالي" },
  { name:"G36", damage:29, fireRate:100, mag:30, reload:1900, type:"rifle", power:0.85, desc:"ألماني - سريع جدا" },
  { name:"AUG", damage:31, fireRate:115, mag:30, reload:2000, type:"rifle", power:0.9, desc:"نمساوي - تصميم غريب" },
  { name:"FAMAS", damage:28, fireRate:90, mag:25, reload:1900, type:"rifle", power:0.85, desc:"فرنسي - أسرع طلق" },
  { name:"MP5", damage:22, fireRate:95, mag:32, reload:1800, type:"smg", power:0.7, desc:"رشاش خفيف قريب" },
  { name:"UZI", damage:20, fireRate:85, mag:32, reload:1700, type:"smg", power:0.65, desc:"إسرائيلي - سريع وخفيف" },
  { name:"P90", damage:24, fireRate:90, mag:50, reload:2400, type:"smg", power:0.75, desc:"مخزن كبير 50 طلقة" },
  { name:"MP7", damage:23, fireRate:100, mag:40, reload:1900, type:"smg", power:0.72, desc:"ألماني صغير وقاتل" },
  { name:"Desert Eagle", damage:65, fireRate:450, mag:7, reload:2000, type:"pistol", power:1.6, desc:"مسدس الصحراء - طلقة بتطير الشبح" },
  { name:"Glock 17", damage:25, fireRate:220, mag:17, reload:1500, type:"pistol", power:0.8, desc:"مسدس نمساوي مشهور" },
  { name:"Beretta M9", damage:26, fireRate:240, mag:15, reload:1600, type:"pistol", power:0.82, desc:"مسدس الجيش الأمريكي" },
  { name:".44 Magnum", damage:70, fireRate:500, mag:6, reload:2300, type:"pistol", power:1.7, desc:"ريفيولفر - أقوى مسدس" },
  { name:"Remington 870", damage:90, fireRate:700, mag:6, reload:2600, type:"shotgun", power:2.2, desc:"شوتغن - بيكسر كل شي" },
  { name:"SPAS-12", damage:85, fireRate:650, mag:8, reload:2800, type:"shotgun", power:2.0, desc:"شوتغن إيطالي ثقيل" },
  { name:"AWP Sniper", damage:100, fireRate:1400, mag:5, reload:3000, type:"sniper", power:2.5, desc:"قناص - طلقة وحدة بتكفي" },
  { name:"Barrett M82", damage:120, fireRate:1600, mag:10, reload:3500, type:"sniper", power:2.8, desc:"قناص مضاد للدروع" },
  { name:"Kar98k", damage:95, fireRate:1200, mag:5, reload:2800, type:"sniper", power:2.3, desc:"قناص كلاسيك" },
];

let current = 0;
let ammo = weapons[0].mag;
let score = 0;
let kills = 0;
let playerHP = 100;
let ghosts = [];
let particles = [];
let shells = [];
let lastShot = 0;
let reloading = false;
let mouse = {x:460, y:260};
let recoil = 0;
let gameOver = false;
let time = 0;

const weaponsDiv = document.getElementById('weapons');
weapons.forEach((w,i)=>{
  const b = document.createElement('div');
  b.className = 'wbtn' + (i===0?' active':'');
  b.innerHTML = `${i+1}. ${w.name}<small>${w.desc} | ضرر ${w.damage} | مخزن ${w.mag}</small>`;
  b.onclick = ()=> selectWeapon(i);
  weaponsDiv.appendChild(b);
});

function selectWeapon(i){
  if(gameOver) return;
  current = i;
  ammo = weapons[i].mag;
  reloading = false;
  document.querySelectorAll('.wbtn').forEach((el,idx)=> el.classList.toggle('active', idx===i));
  updateHUD();
  playClick();
}
function updateHUD(){
  document.getElementById('curName').textContent = weapons[current].name;
  document.getElementById('ammo').textContent = reloading ? 'عم بيعبي...' : `${ammo} / ${weapons[current].mag}`;
  document.getElementById('score').textContent = score;
  document.getElementById('kills').textContent = kills;
  document.getElementById('hpText').textContent = playerHP;
  document.getElementById('hpFill').style.width = playerHP + '%';
  document.getElementById('hpFill').style.background = playerHP > 50 ? '#22c55e' : playerHP > 25 ? '#facc15' : '#ef4444';
}
function restart(){
  score=0; kills=0; playerHP=100; ghosts=[]; particles=[]; gameOver=false;
  document.getElementById('gameOver').style.display='none';
  selectWeapon(0); updateHUD();
}

// ===== الصوت =====
let audioCtx = null;
function getAudio(){
  if(!audioCtx) audioCtx = new (window.AudioContext || window.webkitAudioContext)();
  if(audioCtx.state === 'suspended') audioCtx.resume();
  return audioCtx;
}
function playClick(){
  try{
    const ac = getAudio();
    const o = ac.createOscillator(); const g = ac.createGain();
    o.type='square'; o.frequency.value=800; g.gain.setValueAtTime(0.05, ac.currentTime);
    g.gain.exponentialRampToValueAtTime(0.001, ac.currentTime+0.05);
    o.connect(g); g.connect(ac.destination); o.start(); o.stop(ac.currentTime+0.06);
  }catch(e){}
}
function playGunshot(w){
  try{
    const ac = getAudio();
    const t = ac.currentTime;
    const dur = w.type==='shotgun' ? 0.35 : w.type==='sniper' ? 0.45 : w.type==='pistol' ? 0.18 : 0.22;
    const bufferSize = ac.sampleRate * dur;
    const buffer = ac.createBuffer(1, bufferSize, ac.sampleRate);
    const data = buffer.getChannelData(0);
    for(let i=0;i<bufferSize;i++){
      data[i] = (Math.random()*2-1) * Math.pow(1 - i/bufferSize, 2.2);
    }
    const noise = ac.createBufferSource(); noise.buffer = buffer;
    const filter = ac.createBiquadFilter();
    filter.type = 'lowpass';
    filter.frequency.value = w.type==='sniper' || w.type==='shotgun' ? 800 : w.type==='pistol' ? 2500 : 1500;
    const gain = ac.createGain();
    gain.gain.setValueAtTime(0.9 * w.power, t);
    gain.gain.exponentialRampToValueAtTime(0.001, t+dur);
    noise.connect(filter); filter.connect(gain); gain.connect(ac.destination); noise.start(t);
    const osc = ac.createOscillator(); const og = ac.createGain();
    osc.type='sine';
    osc.frequency.setValueAtTime(w.type==='sniper' || w.type==='shotgun' ? 60 : 120, t);
    osc.frequency.exponentialRampToValueAtTime(30, t+0.15);
    og.gain.setValueAtTime(0.5 * w.power, t);
    og.gain.exponentialRampToValueAtTime(0.001, t+0.18);
    osc.connect(og); og.connect(ac.destination); osc.start(t); osc.stop(t+0.2);
  }catch(e){}
}
function playGhostHit(){
  try{
    const ac = getAudio(); const t = ac.currentTime;
    const o = ac.createOscillator(); const g = ac.createGain();
    o.type='sawtooth'; o.frequency.setValueAtTime(900,t); o.frequency.exponentialRampToValueAtTime(200,t+0.25);
    g.gain.setValueAtTime(0.18,t); g.gain.exponentialRampToValueAtTime(0.001,t+0.26);
    o.connect(g); g.connect(ac.destination); o.start(t); o.stop(t+0.27);
  }catch(e){}
}
function playGhostDie(){
  try{
    const ac = getAudio(); const t = ac.currentTime;
    const o = ac.createOscillator(); const g = ac.createGain();
    o.type='sine'; o.frequency.setValueAtTime(500,t); o.frequency.exponentialRampToValueAtTime(80,t+0.5);
    g.gain.setValueAtTime(0.25,t); g.gain.exponentialRampToValueAtTime(0.001,t+0.5);
    o.connect(g); g.connect(ac.destination); o.start(t); o.stop(t+0.51);
  }catch(e){}
}
function playReload(){
  try{
    const ac = getAudio();
    [0, 350, 750].forEach((d,i)=>{
      setTimeout(()=>{
        const o = ac.createOscillator(); const g = ac.createGain();
        o.type='square'; o.frequency.value = i===2 ? 900 : 400;
        g.gain.setValueAtTime(0.08, ac.currentTime); g.gain.exponentialRampToValueAtTime(0.001, ac.currentTime+0.08);
        o.connect(g); g.connect(ac.destination); o.start(); o.stop(ac.currentTime+0.09);
      }, d);
    });
  }catch(e){}
}

// ===== الأشباح - هون بتبين بوضوح =====
const ghostTypes = [
  { color:'#ffffff', hp:1, speed:1.1, size:55, score:100, name:'شبح عادي' },
  { color:'#a7f3d0', hp:2, speed:1.5, size:48, score:150, name:'شبح أخضر سريع' },
  { color:'#c4b5fd', hp:3, speed:0.9, size:70, score:250, name:'شبح بنفسجي قوي' },
  { color:'#fda4af', hp:5, speed:0.7, size:95, score:500, name:'شبح زعيم 👑' },
];

function spawnGhost(){
  if(gameOver) return;
  // كل 15 قتلة بيطلع زعيم
  let typeIdx = Math.floor(Math.random()*3);
  if(kills>0 && kills % 12 === 0) typeIdx = 3;
  const t = ghostTypes[typeIdx];
  const fromLeft = Math.random() > 0.5;
  ghosts.push({
    x: fromLeft ? -80 : canvas.width + 80,
    y: 80 + Math.random()*260,
    w: t.size, h: t.size * 1.35,
    hp: t.hp, maxHp: t.hp,
    speed: t.speed * (fromLeft ? 1 : -1),
    baseY: 80 + Math.random()*260,
    phase: Math.random()*Math.PI*2,
    color: t.color,
    score: t.score,
    alpha: 0, // بيبين تدريجيا
    scale: 0.5,
    flash: 0,
    type: typeIdx
  });
}
// أول 5 أشباح بيبينوا فورا
for(let i=0;i<5;i++) setTimeout(spawnGhost, i*400);
setInterval(spawnGhost, 1400);
setInterval(()=>{ if(!gameOver && ghosts.length < 3) spawnGhost(); }, 800);

function shoot(x,y){
  if(gameOver) return;
  const now = Date.now();
  const w = weapons[current];
  if(reloading) return;
  if(now - lastShot < w.fireRate) return;
  if(ammo <= 0){ playClick(); reload(); return; }
  lastShot = now;
  ammo--;
  recoil = w.power * 8;
  flashEl.style.left = x + 'px';
  flashEl.style.top = (y - 10) + 'px';
  flashEl.style.opacity = 1;
  flashEl.style.width = (70 + w.power*30)+'px';
  flashEl.style.height = (70 + w.power*30)+'px';
  setTimeout(()=> flashEl.style.opacity = 0, 60);
  shells.push({x: x+10, y: y, vx: 2+Math.random()*3, vy: -4-Math.random()*3, rot:0});
  playGunshot(w);
  updateHUD();

  for(let i=ghosts.length-1; i>=0; i--){
    const g = ghosts[i];
    // منطقة الإصابة أكبر شوي عشان الشبح يبين وينطخ بسهولة
    if(x >= g.x - 10 && x <= g.x+g.w+10 && y >= g.y - 10 && y <= g.y+g.h+10){
      g.hp -= 1;
      g.flash = 1;
      playGhostHit();
      for(let p=0;p<14;p++) particles.push({x:x, y:y, vx:(Math.random()-0.5)*9, vy:(Math.random()-0.5)*9, life:1, color: g.color === '#ffffff' ? '#e2e8f0' : g.color});
      if(g.hp <= 0){
        score += g.score;
        kills++;
        playGhostDie();
        // انفجار شبح
        for(let p=0;p<25;p++) particles.push({x:g.x+g.w/2, y:g.y+g.h/2, vx:(Math.random()-0.5)*10, vy:(Math.random()-0.5)*10, life:1, color:'#ffffff'});
        ghosts.splice(i,1);
      } else {
        score += 20;
      }
      updateHUD();
      break;
    }
  }
}

function reload(){
  const w = weapons[current];
  if(reloading || ammo === w.mag || gameOver) return;
  reloading = true; updateHUD(); playReload();
  setTimeout(()=>{ ammo = w.mag; reloading=false; updateHUD(); }, w.reload);
}

// ===== رسم الشبح - واضح وكبير =====
function drawGhost(g){
  ctx.save();
  ctx.globalAlpha = Math.min(g.alpha, 1);
  ctx.translate(g.x + g.w/2, g.y + g.h/2);
  ctx.scale(g.scale, g.scale);
  // توهج حول الشبح عشان يبين بالليل
  ctx.shadowColor = g.color;
  ctx.shadowBlur = 25;
  // الجسم
  const w = g.w, h = g.h;
  ctx.fillStyle = g.flash > 0 ? '#ef4444' : g.color;
  ctx.beginPath();
  ctx.moveTo(-w/2, h/2 - 12);
  ctx.lineTo(-w/2, -h/4);
  ctx.arc(0, -h/4, w/2, Math.PI, 0);
  ctx.lineTo(w/2, h/2 - 12);
  // ذيل متموج
  const waves = 4;
  const step = w / waves;
  for(let i=0;i<waves;i++){
    const x1 = w/2 - i*step;
    const x2 = w/2 - (i+1)*step;
    const midX = (x1+x2)/2;
    const midY = h/2 - (i%2===0 ? 18 : 4);
    ctx.quadraticCurveTo(midX, midY, x2, h/2 - 12);
  }
  ctx.closePath();
  ctx.fill();
  ctx.shadowBlur = 0;
  // عيون
  ctx.fillStyle = '#111';
  ctx.beginPath(); ctx.ellipse(-w*0.18, -h*0.15, w*0.09, h*0.11, 0, 0, Math.PI*2); ctx.fill();
  ctx.beginPath(); ctx.ellipse(w*0.18, -h*0.15, w*0.09, h*0.11, 0, 0, Math.PI*2); ctx.fill();
  // بؤبؤ أبيض صغير
  ctx.fillStyle = '#fff';
  ctx.beginPath(); ctx.arc(-w*0.18 + 3, -h*0.15 - 3, 2.5, 0, Math.PI*2); ctx.fill();
  ctx.beginPath(); ctx.arc(w*0.18 + 3, -h*0.15 - 3, 2.5, 0, Math.PI*2); ctx.fill();
  // فم مخيف
  ctx.fillStyle = '#111';
  ctx.beginPath(); ctx.ellipse(0, h*0.12, w*0.13, h*0.12, 0, 0, Math.PI*2); ctx.fill();
  // يدين صغيرتين
  ctx.fillStyle = g.color;
  ctx.beginPath(); ctx.arc(-w/2 - 4, h*0.05, 9, 0, Math.PI*2); ctx.fill();
  ctx.beginPath(); ctx.arc(w/2 + 4, h*0.05, 9, 0, Math.PI*2); ctx.fill();
  ctx.restore();
  // شريط دم الشبح الكبير
  if(g.maxHp > 1){
    ctx.fillStyle = 'rgba(0,0,0,0.6)'; ctx.fillRect(g.x, g.y - 14, g.w, 7);
    ctx.fillStyle = '#ef4444'; ctx.fillRect(g.x, g.y - 14, g.w * (g.hp / g.maxHp), 7);
  }
}

function drawBackground(){
  // سماء ليلية
  const grad = ctx.createLinearGradient(0,0,0,540);
  grad.addColorStop(0,'#0f0f2a'); grad.addColorStop(0.6,'#1a1a3a'); grad.addColorStop(1,'#0a0a15');
  ctx.fillStyle = grad; ctx.fillRect(0,0,canvas.width,canvas.height);
  // قمر
  ctx.fillStyle = '#fef9c3'; ctx.beginPath(); ctx.arc(790,75,42,0,Math.PI*2); ctx.fill();
  ctx.fillStyle = 'rgba(254,249,195,0.25)'; ctx.beginPath(); ctx.arc(790,75,65,0,Math.PI*2); ctx.fill();
  // نجوم
  ctx.fillStyle = '#fff';
  for(let i=0;i<40;i++){
    const sx = (i*137)%920, sy = (i*73)%220;
    ctx.globalAlpha = 0.3 + (Math.sin(time*2 + i)*0.3);
    ctx.fillRect(sx, sy, 2, 2);
  }
  ctx.globalAlpha = 1;
  // بيت مسكون
  ctx.fillStyle = '#0a0a18'; ctx.fillRect(40,180,180,180);
  ctx.fillStyle = '#1e1e35'; ctx.beginPath(); ctx.moveTo(20,185); ctx.lineTo(130,110); ctx.lineTo(240,185); ctx.closePath(); ctx.fill();
  ctx.fillStyle = '#facc15'; ctx.fillRect(80,230,30,35); ctx.fillRect(150,230,30,35);
  ctx.fillStyle = '#0a0a18'; ctx.fillRect(115,300,35,60);
  // شواهد قبور
  ctx.fillStyle = '#2d2d44';
  ctx.fillRect(320, 340, 28, 50); ctx.fillRect(550, 350, 28, 45); ctx.fillRect(680, 335, 30, 55);
  ctx.fillStyle = '#3a3a55'; ctx.beginPath(); ctx.arc(334,340,14,Math.PI,0); ctx.fill(); ctx.fillRect(320,340,28,18);
  // أرض
  ctx.fillStyle = '#141422'; ctx.fillRect(0,390,canvas.width,150);
  ctx.fillStyle = '#1e1e35'; ctx.fillRect(0,390,canvas.width,6);
}

function draw(){
  time += 0.016;
  ctx.clearRect(0,0,canvas.width,canvas.height);
  drawBackground();

  // تحديث الأشباح
  ghosts.forEach(g=>{
    // ظهور تدريجي - عشان يبين
    if(g.alpha < 1) g.alpha += 0.03;
    if(g.scale < 1) g.scale += 0.02;
    if(g.flash > 0) g.flash -= 0.08;
    g.x += g.speed;
    g.y = g.baseY + Math.sin(time*2 + g.phase) * 18;
    // إذا وصل الشبح لعندك
    if(g.x > canvas.width/2 - 80 && g.x < canvas.width/2 + 80 && g.y > 340){
      playerHP -= 8;
      ghosts.splice(ghosts.indexOf(g),1);
      updateHUD();
      if(playerHP <= 0){
        playerHP = 0; gameOver = true;
        document.getElementById('finalScore').textContent = 'جبت ' + score + ' نقطة وقتلت ' + kills + ' شبح';
        document.getElementById('gameOver').style.display = 'block';
        updateHUD();
      }
    }
    // إذا طلع برا الشاشة رجعه من الجهة الثانية
    if(g.speed > 0 && g.x > canvas.width + 100) g.x = -90;
    if(g.speed < 0 && g.x < -100) g.x = canvas.width + 90;
  });

  // رسم الأشباح - كلهم ببينوا
  ghosts.forEach(drawGhost);

  // جزيئات
  particles = particles.filter(p=> p.life>0);
  particles.forEach(p=>{
    p.x+=p.vx; p.y+=p.vy; p.vy+=0.2; p.life-=0.03;
    ctx.globalAlpha = Math.max(p.life,0); ctx.fillStyle=p.color;
    ctx.beginPath(); ctx.arc(p.x,p.y,4,0,Math.PI*2); ctx.fill();
  });
  ctx.globalAlpha=1;

  // ظروف الطلق
  shells = shells.filter(s=> s.y < canvas.height);
  shells.forEach(s=>{
    s.x+=s.vx; s.y+=s.vy; s.vy+=0.4; s.rot+=0.2;
    ctx.save(); ctx.translate(s.x,s.y); ctx.rotate(s.rot);
    ctx.fillStyle='#facc15'; ctx.fillRect(-3,-6,6,12); ctx.restore();
  });

  // السلاح من تحت
  const gunY = canvas.height - 55 + recoil;
  ctx.fillStyle = '#111'; ctx.fillRect(canvas.width/2 - 100, gunY, 200, 42);
  ctx.fillStyle = '#333'; ctx.fillRect(canvas.width/2 - 100, gunY, 200, 10);
  ctx.fillStyle = '#c084fc'; ctx.font='bold 14px Arial'; ctx.textAlign='center';
  ctx.fillText(weapons[current].name + '  |  ' + ammo + ' طلقة', canvas.width/2, gunY+28);
  if(reloading){
    ctx.fillStyle='#f87171'; ctx.font='bold 18px Arial';
    ctx.fillText('... عم بعبي ...', canvas.width/2, gunY-18);
  }
  // تصويب أحمر
  ctx.strokeStyle='#ef4444'; ctx.lineWidth=2;
  ctx.beginPath(); ctx.arc(mouse.x, mouse.y, 20, 0, Math.PI*2); ctx.stroke();
  ctx.beginPath(); ctx.moveTo(mouse.x-26, mouse.y); ctx.lineTo(mouse.x+26, mouse.y); ctx.moveTo(mouse.x, mouse.y-26); ctx.lineTo(mouse.x, mouse.y+26); ctx.stroke();
  ctx.fillStyle='#ef4444'; ctx.beginPath(); ctx.arc(mouse.x, mouse.y, 2.5, 0, Math.PI*2); ctx.fill();

  if(recoil>0) recoil*=0.85;
  requestAnimationFrame(draw);
}
draw();
updateHUD();

canvas.addEventListener('mousemove', e=>{
  const r = canvas.getBoundingClientRect();
  mouse.x = (e.clientX - r.left) * (canvas.width / r.width);
  mouse.y = (e.clientY - r.top) * (canvas.height / r.height);
});
canvas.addEventListener('mousedown', e=>{
  getAudio();
  const r = canvas.getBoundingClientRect();
  const x = (e.clientX - r.left) * (canvas.width / r.width);
  const y = (e.clientY - r.top) 

Game Source: لعبة طخ الأشباح - 20 سلاح

Creator: ChromeFlame24

Libraries: none

Complexity: complex (460 lines, 20.5 KB)

The full source code is displayed above on this page.

Remix Instructions

To remix this game, copy the source code above and modify it. Add a ARCADELAB header at the top with "remix_of: 20-chromeflame24-mwn42oaz" to link back to the original. Then publish at arcadelab.ai/publish.