🎮ArcadeLab

LOOM GALAXY ATTACK - ZOMBIE

by MegaOtter89
188 lines9.2 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>LOOM GALAXY ATTACK - ZOMBIE</title>
<style>
*{box-sizing:border-box;font-family:Tahoma}
body{margin:0;background:#0a0a1f;color:#fff;text-align:center}
h1{margin:5px 0 0;color:#FFD700;font-size:30px;line-height:1;text-shadow:0 0 12px red}
h1 span{color:#fff}
p{margin:0;color:#ff8c00;letter-spacing:8px;font-weight:bold}
#hud{display:flex;justify-content:space-around;background:#11113a;padding:8px;font-size:14px}
#hud b{color:#FFD700}
canvas{background:radial-gradient(#1a0a3a,#050514);display:block;margin:5px auto;border:2px solid #FFD700;border-radius:12px;touch-action:none;max-width:95vw}
button{background:#FFD700;color:#000;border:none;padding:10px 16px;border-radius:10px;font-weight:bold;margin:4px;cursor:pointer}
</style>
</head>
<body>
<h1>LOOM<br><span>GALAXY</span></h1><p>A T T A C K</p>
<div id="hud"><div>نقاط: <b id="score">0</b></div><div>موجة: <b id="wave">1</b></div><div>عملات: <b id="coins">0</b></div><div>صحة: <b id="hp">100</b></div></div>
<canvas id="game" width="400" height="520"></canvas>
<div><button onclick="startGame()">▶ العب</button><button onclick="paused=!paused">⏸ إيقاف</button></div>

<script>
const canvas=document.getElementById('game'), ctx=canvas.getContext('2d');
let score=0, wave=1, coins=0, running=false, paused=false;
let player={x:200,y:450,hp:100,maxHp:100};
let bullets=[], enemies=[], parts=[], drops=[];
let timer=0, shootTimer=0;

function startGame(){score=0;wave=1;coins=0;player.hp=100;player.x=200;bullets=[];enemies=[];parts=[];drops=[];running=true;paused=false;updateHUD();}
function updateHUD(){document.getElementById('score').textContent=score;document.getElementById('wave').textContent=wave;document.getElementById('coins').textContent=coins;document.getElementById('hp').textContent=player.hp;}

function spawnEnemy(){
  let r=Math.random();
  let type = r<0.5 ? 'normal' : r<0.8 ? 'fast' : r<0.95 ? 'tank' : 'boss';
  let e={x:40+Math.random()*320,y:-40,type:type,vy:0,r:22};
  if(type==='normal'){e.r=22;e.vy=1.1;e.hp=3;e.color='#7AC74F';e.eye='#FF0000';}
  if(type==='fast'){e.r=18;e.vy=1.9;e.hp=2;e.color='#4CAF50';e.eye='#FFFF00';}
  if(type==='tank'){e.r=30;e.vy=0.7;e.hp=8;e.color='#2E7D32';e.eye='#FF5722';}
  if(type==='boss'){e.r=45;e.vy=0.5;e.hp=30;e.color='#6A1B9A';e.eye='#FF0000';}
  enemies.push(e);
}

// رسم السفينة - مرسومة بالتفصيل مش مثلث
function drawPlayer(){
  ctx.save();ctx.translate(player.x,player.y);
  // نار المحرك
  ctx.fillStyle='#FF8C00';
  ctx.beginPath();ctx.moveTo(-6,22);ctx.lineTo(0,38+Math.random()*8);ctx.lineTo(6,22);ctx.closePath();ctx.fill();
  ctx.fillStyle='#FFFF00';
  ctx.beginPath();ctx.moveTo(-3,22);ctx.lineTo(0,32);ctx.lineTo(3,22);ctx.closePath();ctx.fill();
  // أجنحة
  ctx.fillStyle='#1E90FF';
  ctx.beginPath();ctx.moveTo(-28,18);ctx.lineTo(-10,-5);ctx.lineTo(-10,18);ctx.closePath();ctx.fill();
  ctx.beginPath();ctx.moveTo(28,18);ctx.lineTo(10,-5);ctx.lineTo(10,18);ctx.closePath();ctx.fill();
  // جسم السفينة
  let grad=ctx.createLinearGradient(0,-28,0,22);
  grad.addColorStop(0,'#FFD700');grad.addColorStop(1,'#FF4500');
  ctx.fillStyle=grad;
  ctx.beginPath();ctx.moveTo(0,-28);ctx.bezierCurveTo(10,-10,10,15,0,22);ctx.bezierCurveTo(-10,15,-10,-10,0,-28);ctx.fill();
  // قمرة القيادة
  ctx.fillStyle='#00FFFF';
  ctx.beginPath();ctx.ellipse(0,-5,5,9,0,0,Math.PI*2);ctx.fill();
  ctx.fillStyle='#fff';ctx.beginPath();ctx.ellipse(-1,-8,2,3,0,0,Math.PI*2);ctx.fill();
  // خطوط ذهبية
  ctx.strokeStyle='#FFD700';ctx.lineWidth=2;ctx.beginPath();ctx.moveTo(-8,10);ctx.lineTo(8,10);ctx.stroke();
  ctx.restore();
}

// رسم الزومبي - مرسوم بالكانفس مش مربع ولا إيموجي
function drawZombie(e){
  ctx.save();ctx.translate(e.x,e.y);
  // أذنين
  ctx.fillStyle=e.color;
  ctx.beginPath();ctx.arc(-e.r,0,6,0,Math.PI*2);ctx.fill();
  ctx.beginPath();ctx.arc(e.r,0,6,0,Math.PI*2);ctx.fill();
  // راس
  ctx.fillStyle=e.color;
  ctx.beginPath();ctx.arc(0,0,e.r,0,Math.PI*2);ctx.fill();
  // ظل الراس
  ctx.fillStyle='rgba(0,0,0,0.2)';
  ctx.beginPath();ctx.arc(0,4,e.r*0.8,0,Math.PI*2);ctx.fill();
  // قرون للبوس
  if(e.type==='boss'){
    ctx.fillStyle='#fff';
    ctx.beginPath();ctx.moveTo(-18,-e.r+5);ctx.lineTo(-10,-e.r-18);ctx.lineTo(-4,-e.r+5);ctx.closePath();ctx.fill();
    ctx.beginPath();ctx.moveTo(18,-e.r+5);ctx.lineTo(10,-e.r-18);ctx.lineTo(4,-e.r+5);ctx.closePath();ctx.fill();
  }
  // جروح
  ctx.strokeStyle='rgba(0,0,0,0.35)';ctx.lineWidth=1.5;
  ctx.beginPath();ctx.moveTo(-e.r*0.6,-e.r*0.3);ctx.lineTo(-e.r*0.3,-e.r*0.1);ctx.stroke();
  // عيون - بيضاوي حمرا
  ctx.fillStyle='#fff';
  ctx.beginPath();ctx.ellipse(-e.r*0.4,-e.r*0.1,7,8,0,0,Math.PI*2);ctx.fill();
  ctx.beginPath();ctx.ellipse(e.r*0.4,-e.r*0.1,7,8,0,0,Math.PI*2);ctx.fill();
  ctx.fillStyle=e.eye;
  ctx.beginPath();ctx.arc(-e.r*0.4,-e.r*0.1,4,0,Math.PI*2);ctx.fill();
  ctx.beginPath();ctx.arc(e.r*0.4,-e.r*0.1,4,0,Math.PI*2);ctx.fill();
  ctx.fillStyle='#000';
  ctx.beginPath();ctx.arc(-e.r*0.4,-e.r*0.1,1.8,0,Math.PI*2);ctx.fill();
  ctx.beginPath();ctx.arc(e.r*0.4,-e.r*0.1,1.8,0,Math.PI*2);ctx.fill();
  // حواجب غاضبة
  ctx.strokeStyle='#000';ctx.lineWidth=3;
  ctx.beginPath();ctx.moveTo(-e.r*0.65,-e.r*0.5);ctx.lineTo(-e.r*0.15,-e.r*0.3);ctx.stroke();
  ctx.beginPath();ctx.moveTo(e.r*0.65,-e.r*0.5);ctx.lineTo(e.r*0.15,-e.r*0.3);ctx.stroke();
  // فم
  ctx.fillStyle='#3E2723';
  ctx.beginPath();ctx.ellipse(0,e.r*0.45,e.r*0.5,8,0,0,Math.PI*2);ctx.fill();
  // سنان
  ctx.fillStyle='#fff';
  for(let i=-2;i<=2;i++){ctx.fillRect(i*5-2,e.r*0.45-7,4,6);}
  // دم أخضر صغير
  if(e.type==='tank'||e.type==='boss'){
    ctx.fillStyle='#00E676';
    ctx.beginPath();ctx.arc(-e.r*0.5,e.r*0.7,4,0,Math.PI*2);ctx.fill();
  }
  ctx.restore();
  // شريط صحة فوق الزومبي
  ctx.fillStyle='#333';ctx.fillRect(e.x-e.r,e.y-e.r-12,e.r*2,5);
  ctx.fillStyle='#00FF00';ctx.fillRect(e.x-e.r,e.y-e.r-12,e.r*2*(e.hp/(e.type==='boss'?30:e.type==='tank'?8:3)),5);
}

canvas.addEventListener('pointermove',e=>{
  let r=canvas.getBoundingClientRect();
  player.x=(e.clientX-r.left)*(canvas.width/r.width);
  player.y=(e.clientY-r.top)*(canvas.height/r.height);
  if(player.y>480)player.y=480; if(player.y<100)player.y=100;
});
canvas.addEventListener('pointerdown',()=>{if(!running)startGame();});

function loop(){
  requestAnimationFrame(loop);
  if(!running||paused){if(!running)drawStart();return;}
  shootTimer++; if(shootTimer>18){bullets.push({x:player.x-8,y:player.y-20});bullets.push({x:player.x+8,y:player.y-20});shootTimer=0;}
  timer++; if(timer>55){spawnEnemy();timer=0;if(Math.random()<0.06)wave++;}
  bullets.forEach(b=>b.y-=8); bullets=bullets.filter(b=>b.y>-10);
  enemies.forEach(e=>{e.y+=e.vy; e.x+=Math.sin(e.y/30)*0.6;});
  enemies=enemies.filter(e=>e.y<580);
  parts.forEach(p=>{p.x+=p.vx;p.y+=p.vy;p.life--;}); parts=parts.filter(p=>p.life>0);
  drops.forEach(d=>d.y+=2); drops=drops.filter(d=>d.y<560);
  // تصادم رصاص مع زومبي
  bullets.forEach((b,bi)=>{enemies.forEach((e,ei)=>{
    let dx=b.x-e.x, dy=b.y-e.y;
    if(Math.sqrt(dx*dx+dy*dy)<e.r+6){
      e.hp-=1; bullets.splice(bi,1);
      if(e.hp<=0){
        score+=e.type==='boss'?500:50; coins+=e.type==='boss'?50:5;
        for(let i=0;i<14;i++)parts.push({x:e.x,y:e.y,vx:(Math.random()-0.5)*5,vy:(Math.random()-0.5)*5,life:25,c:e.color});
        drops.push({x:e.x,y:e.y}); enemies.splice(ei,1);
      }
    }});
  });
  enemies.forEach((e,ei)=>{
    if(Math.abs(e.x-player.x)<e.r*0.7+12 && Math.abs(e.y-player.y)<e.r*0.7+12){player.hp-=12;enemies.splice(ei,1); if(player.hp<=0){running=false;alert('انتهت اللعبة! نقاطك: '+score+' - عملاتك: '+coins);}}
  });
  drops.forEach((d,di)=>{if(Math.abs(d.x-player.x)<22&&Math.abs(d.y-player.y)<22){coins+=5;drops.splice(di,1);}});
  updateHUD(); draw();
}
function drawStart(){
  ctx.fillStyle='#050514';ctx.fillRect(0,0,400,520);
  ctx.fillStyle='#FFD700';ctx.font='bold 28px Tahoma';ctx.textAlign='center';
  ctx.fillText('LOOM GALAXY',200,200);ctx.fillStyle='#fff';ctx.fillText('ATTACK',200,240);
  ctx.fillStyle='#7AC74F';ctx.font='16px Tahoma';ctx.fillText('الزومبي جايين! دافع عن المجرة',200,300);
  ctx.fillStyle='#FF8C00';ctx.fillText('اكبس العب واسحب اصبعك لتحرك',200,330);
}
function draw(){
  ctx.fillStyle='#0a0a2a';ctx.fillRect(0,0,400,520);
  for(let i=0;i<60;i++){ctx.fillStyle='#fff';ctx.fillRect((i*73)%400,(i*47+Date.now()/25)%520,2,2);}
  // رصاص مرسوم كليزر
  bullets.forEach(b=>{
    ctx.fillStyle='#FFFF00';ctx.beginPath();ctx.ellipse(b.x,b.y,3,10,0,0,Math.PI*2);ctx.fill();
    ctx.fillStyle='#FF0000';ctx.beginPath();ctx.ellipse(b.x,b.y,1.5,6,0,0,Math.PI*2);ctx.fill();
  });
  enemies.forEach(drawZombie);
  drops.forEach(d=>{
    ctx.fillStyle='#FFD700';ctx.beginPath();ctx.arc(d.x,d.y,8,0,Math.PI*2);ctx.fill();
    ctx.fillStyle='#000';ctx.font='bold 10px Tahoma';ctx.textAlign='center';ctx.fillText('$',d.x,d.y+3);
  });
  parts.forEach(p=>{ctx.fillStyle=p.c;ctx.beginPath();ctx.arc(p.x,p.y,4,0,Math.PI*2);ctx.fill();});
  drawPlayer();
}
updateHUD(); drawStart();
requestAnimationFrame(loop);
</script>
</body>
</html>

Game Source: LOOM GALAXY ATTACK - ZOMBIE

Creator: MegaOtter89

Libraries: none

Complexity: moderate (188 lines, 9.2 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: loom-galaxy-attack-zombie-megaotter89" to link back to the original. Then publish at arcadelab.ai/publish.