هجوم المجرة v2 - تحديث الحوار والحركة
by ChromeFlame24376 lines20.4 KB
<!DOCTYPE html>
<html lang="ar" dir="rtl">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>هجوم المجرة v2 - تحديث الحوار والحركة</title>
<style>
body{margin:0; background:#050510; color:#fff; font-family:Tahoma; text-align:center;}
.top{background:#0a0a25; padding:12px; border-bottom:3px solid #00e5ff; display:flex; justify-content:center; gap:18px; flex-wrap:wrap; font-weight:bold; font-size:14px;}
.top span{color:#facc15;}
#wrap{position:relative; max-width:920px; margin:15px auto; padding:0 10px;}
canvas#game{width:100%; height:540px; background:#050510; border:3px solid #00e5ff; border-radius:14px; cursor:none; display:block;}
/* صندوق الحوار - على الشمال زي الألعاب */
#dialogueBox{position:absolute; bottom:18px; right:18px; left:18px; background:rgba(5,5,20,0.95); border:3px solid #a855f7; border-radius:15px; display:none; padding:12px; gap:12px; align-items:center; text-align:right; z-index:20; cursor:pointer; animation:slideIn 0.4s;}
@keyframes slideIn{from{transform:translateX(-100%); opacity:0} to{transform:translateX(0); opacity:1}}
#portrait{width:110px; height:110px; border-radius:50%; border:3px solid #a855f7; background:#1a1a35; flex-shrink:0;}
#dialogueName{color:#facc15; font-weight:bold; font-size:16px; margin-bottom:5px;}
#dialogueName.boss{color:#ff4444;}
#dialogueName.player{color:#00e5ff;}
#dialogueText{font-size:17px; line-height:1.6; min-height:50px;}
#dialogueHint{font-size:12px; color:#aaa; margin-top:6px; animation:blink 1s infinite;}
@keyframes blink{0%,100%{opacity:1} 50%{opacity:0.3}}
.btns{margin:10px; display:flex; gap:8px; justify-content:center; flex-wrap:wrap;}
.btns button{background:#00e5ff; color:#000; border:none; padding:10px 18px; border-radius:10px; font-weight:bold; cursor:pointer;}
#weapons{display:flex; gap:8px; justify-content:center; flex-wrap:wrap; margin:5px;}
.wbtn{background:#222; border:2px solid #555; color:#fff; padding:9px 14px; border-radius:10px; cursor:pointer; font-weight:bold;}
.wbtn.active{background:#00e5ff; color:#000; border-color:#00e5ff;}
.hint{color:#ccc; font-size:13px; padding-bottom:15px;}
.hint b{color:#facc15;}
#gameOver{position:absolute; top:50%; left:50%; transform:translate(-50%,-50%); background:rgba(0,0,0,0.92); padding:25px 35px; border-radius:15px; text-align:center; border:2px solid #ff4444; display:none; z-index:30;}
#gameOver button{background:#ff4444; color:#fff; border:none; padding:12px 25px; border-radius:10px; font-size:16px; cursor:pointer; margin-top:10px;}
</style>
</head>
<body>
<div class="top">
<div>النقاط: <span id="score">0</span></div>
<div>القتل: <span id="kills">0</span></div>
<div>الصحة: <span id="hp">100</span></div>
<div>المرحلة: <span id="level">1</span></div>
<div>السلاح: <span id="curWeapon">ليزر مزدوج</span></div>
</div>
<div id="wrap">
<canvas id="game" width="900" height="540"></canvas>
<!-- صندوق الحوار -->
<div id="dialogueBox" onclick="nextDialogue()">
<canvas id="portrait" width="110" height="110"></canvas>
<div style="flex:1;">
<div id="dialogueName">الزعيم</div>
<div id="dialogueText"></div>
<div id="dialogueHint">اضغط هون للمتابعة ...</div>
</div>
</div>
<div id="gameOver">
<h2 style="color:#ff4444; margin:0;">انتهت اللعبة! سفينتك تدمرت</h2>
<p id="finalScore"></p>
<button onclick="restart()">العب مرة ثانية</button>
</div>
</div>
<div id="weapons"></div>
<div class="btns">
<button onclick="startIntro()">اعادة الحوار من جديد</button>
<button onclick="heal()" style="background:#facc15;">اصلاح السفينة - 100 نقطة</button>
</div>
<p class="hint">تحديث جديد: السفينة بتميل لما تتحرك، والزعيم بيحكي معك • <b>اضغط على صندوق الحوار</b> عشان تكمل الحكي</p>
<script>
const canvas = document.getElementById('game');
const ctx = canvas.getContext('2d');
const portraitCanvas = document.getElementById('portrait');
const pctx = portraitCanvas.getContext('2d');
const weapons = [
{ name:"ليزر واحد", damage:1, fireRate:180, bullets:1, color:"#facc15" },
{ name:"ليزر مزدوج", damage:1, fireRate:170, bullets:2, color:"#00e5ff" },
{ name:"ليزر ثلاثي", damage:1, fireRate:200, bullets:3, color:"#ff00ff" },
];
let currentWeapon = 1;
let score = 0, kills = 0, level = 1, gameOver = false;
let player = { x:450, y:470, w:56, h:58, hp:100, speed:5, lastShot:0, powerTime:0, tilt:0 };
let bullets = [], enemyBullets = [], enemies = [], particles = [], stars = [], powerUps = [];
let keys = {}, mouse = {x:450, y:470}, time = 0;
let dialogueActive = true; // بالبداية الحوار شغال واللعبة واقفة
for(let i=0;i<90;i++) stars.push({x:Math.random()*900, y:Math.random()*540, s:Math.random()*2+0.5, speed:Math.random()*1.5+0.5});
// ================= نظام الحوار =================
const introDialogues = [
{ name:"الزعيم زورغ", type:"boss", text:"ههههههه ... أخيرا وصلت يا بطل المجرة؟" },
{ name:"الزعيم زورغ", type:"boss", text:"أنا راح أقتلك وأدمر سفينتك! المجرة كلها راح تكون إلي!" },
{ name:"أنت - البطل", type:"player", text:"مش راح تقدر! أنا جيت أوقفك، وراح أدمر كل وحوشك!" },
{ name:"الزعيم زورغ", type:"boss", text:"نشوف ... ابعتوا الوحوش! هجوم!" },
{ name:"أنت - البطل", type:"player", text:"يلا نبلش! راح أوريك شو يعني بطل!" },
];
const bossDialogues = [
{ name:"الزعيم الكبير", type:"boss", text:"كفى! قتلت كل وحوشي ... هسا أنا راح أقتلك بنفسي!" },
{ name:"أنت - البطل", type:"player", text:"أخيرا طلعت! كنت مستنيك، تعال واجهني!" },
{ name:"الزعيم الكبير", type:"boss", text:"راح تندم أنك جيت لهون!" },
];
let currentDialogues = [];
let dialogueIndex = 0;
let dialogueCallback = null;
let typingInterval = null;
function drawPortrait(type){
pctx.clearRect(0,0,110,110);
// خلفية
pctx.fillStyle = type==='boss' ? '#2a0a2a' : '#0a2a3a';
pctx.fillRect(0,0,110,110);
if(type==='boss'){
// وحش زعيم مرسوم
pctx.fillStyle = '#7c3aed';
pctx.beginPath(); pctx.arc(55,60,38,0,Math.PI*2); pctx.fill();
// قرون
pctx.strokeStyle = '#7c3aed'; pctx.lineWidth = 6;
pctx.beginPath(); pctx.moveTo(30,30); pctx.lineTo(20,8); pctx.moveTo(80,30); pctx.lineTo(90,8); pctx.stroke();
pctx.fillStyle = '#facc15';
pctx.beginPath(); pctx.arc(20,8,6,0,Math.PI*2); pctx.fill();
pctx.beginPath(); pctx.arc(90,8,6,0,Math.PI*2); pctx.fill();
// عيون حمراء غاضبة
pctx.fillStyle = '#fff';
pctx.beginPath(); pctx.arc(38,55,10,0,Math.PI*2); pctx.fill();
pctx.beginPath(); pctx.arc(72,55,10,0,Math.PI*2); pctx.fill();
pctx.fillStyle = '#ff0000';
pctx.beginPath(); pctx.arc(38,55,5,0,Math.PI*2); pctx.fill();
pctx.beginPath(); pctx.arc(72,55,5,0,Math.PI*2); pctx.fill();
// حواجب غاضبة
pctx.strokeStyle = '#111'; pctx.lineWidth = 4;
pctx.beginPath(); pctx.moveTo(28,42); pctx.lineTo(48,50); pctx.moveTo(82,42); pctx.lineTo(62,50); pctx.stroke();
// فم شرير
pctx.fillStyle = '#111';
pctx.beginPath(); pctx.ellipse(55,82,16,8,0,0,Math.PI*2); pctx.fill();
pctx.fillStyle = '#fff';
pctx.fillRect(45,78,5,6); pctx.fillRect(60,78,5,6);
} else {
// البطل - طيار مرسوم
pctx.fillStyle = '#fde68a';
pctx.beginPath(); pctx.arc(55,60,36,0,Math.PI*2); pctx.fill();
// خوذة طيار
pctx.fillStyle = '#00e5ff';
pctx.beginPath(); pctx.arc(55,45,38,Math.PI,0); pctx.fill();
pctx.fillStyle = '#0a0a25';
pctx.fillRect(0,0,110,22);
// عيون مصممة
pctx.fillStyle = '#fff';
pctx.beginPath(); pctx.arc(40,60,9,0,Math.PI*2); pctx.fill();
pctx.beginPath(); pctx.arc(70,60,9,0,Math.PI*2); pctx.fill();
pctx.fillStyle = '#111';
pctx.beginPath(); pctx.arc(40,60,4,0,Math.PI*2); pctx.fill();
pctx.beginPath(); pctx.arc(70,60,4,0,Math.PI*2); pctx.fill();
// ابتسامة واثقة
pctx.strokeStyle = '#111'; pctx.lineWidth = 3;
pctx.beginPath(); pctx.arc(55,76,14,0.2,Math.PI-0.2); pctx.stroke();
}
}
function showDialogue(lines, callback){
dialogueActive = true;
currentDialogues = lines;
dialogueIndex = 0;
dialogueCallback = callback;
document.getElementById('dialogueBox').style.display = 'flex';
showOneLine();
}
function showOneLine(){
const line = currentDialogues[dialogueIndex];
const nameEl = document.getElementById('dialogueName');
nameEl.textContent = line.name;
nameEl.className = line.type==='boss' ? 'boss' : 'player';
drawPortrait(line.type);
// تأثير الكتابة حرف حرف
const textEl = document.getElementById('dialogueText');
textEl.textContent = '';
let i = 0;
clearInterval(typingInterval);
typingInterval = setInterval(()=>{
if(i < line.text.length){ textEl.textContent += line.text[i]; i++; }
else clearInterval(typingInterval);
}, 30);
}
function nextDialogue(){
const line = currentDialogues[dialogueIndex];
const textEl = document.getElementById('dialogueText');
// إذا لسه عم يكتب، كمل النص كله
if(textEl.textContent.length < line.text.length){
clearInterval(typingInterval);
textEl.textContent = line.text;
return;
}
dialogueIndex++;
if(dialogueIndex >= currentDialogues.length){
document.getElementById('dialogueBox').style.display = 'none';
dialogueActive = false;
if(dialogueCallback) dialogueCallback();
} else {
showOneLine();
}
}
function startIntro(){
showDialogue(introDialogues, ()=>{
// بعد الحوار بتبلش اللعبة
});
}
// ================= باقي اللعبة =================
const weaponsDiv = document.getElementById('weapons');
function renderWeapons(){
weaponsDiv.innerHTML = '';
weapons.forEach((w,i)=>{
const b = document.createElement('div');
b.className = 'wbtn' + (i===currentWeapon?' active':'');
b.textContent = (i+1) + '. ' + w.name;
b.onclick = ()=>{ currentWeapon=i; renderWeapons(); updateHUD(); playClick(); };
weaponsDiv.appendChild(b);
});
}
function updateHUD(){
document.getElementById('score').textContent = score;
document.getElementById('kills').textContent = kills;
document.getElementById('hp').textContent = Math.max(0, Math.floor(player.hp));
document.getElementById('level').textContent = level;
document.getElementById('curWeapon').textContent = weapons[currentWeapon].name;
}
function restart(){
score=0; kills=0; level=1; player.hp=100; player.x=450; player.y=470;
bullets=[]; enemyBullets=[]; enemies=[]; particles=[]; powerUps=[]; gameOver=false;
document.getElementById('gameOver').style.display='none';
updateHUD();
startIntro();
}
function heal(){ if(score>=100 && player.hp<100){ score-=100; player.hp=Math.min(100, player.hp+40); 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.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 playShoot(){ try{ const ac=getAudio(); const o=ac.createOscillator(); const g=ac.createGain(); o.type='square'; o.frequency.setValueAtTime(900,ac.currentTime); o.frequency.exponentialRampToValueAtTime(300,ac.currentTime+0.08); g.gain.setValueAtTime(0.06,ac.currentTime); g.gain.exponentialRampToValueAtTime(0.001,ac.currentTime+0.09); o.connect(g); g.connect(ac.destination); o.start(); o.stop(ac.currentTime+0.1);}catch(e){} }
function playExplosion(){ try{ const ac=getAudio(); const t=ac.currentTime; const dur=0.35; const buf=ac.createBuffer(1,ac.sampleRate*dur,ac.sampleRate); const d=buf.getChannelData(0); for(let i=0;i<d.length;i++) d[i]=(Math.random()*2-1)*Math.pow(1-i/d.length,1.5); const n=ac.createBufferSource(); n.buffer=buf; const f=ac.createBiquadFilter(); f.type='lowpass'; f.frequency.value=600; const g=ac.createGain(); g.gain.setValueAtTime(0.5,t); g.gain.exponentialRampToValueAtTime(0.001,t+dur); n.connect(f); f.connect(g); g.connect(ac.destination); n.start(t);}catch(e){} }
// رسم السفينة مع حركة الميلان
function drawShip(){
ctx.save();
ctx.translate(player.x, player.y);
ctx.rotate(player.tilt); // هون التحديث - السفينة بتميل
const flame = 12 + Math.sin(time*20)*6;
ctx.fillStyle = '#ff9900';
ctx.beginPath(); ctx.moveTo(-8, 29); ctx.lineTo(0, 29+flame+12); ctx.lineTo(8, 29); ctx.closePath(); ctx.fill();
ctx.fillStyle = '#facc15';
ctx.beginPath(); ctx.moveTo(-4, 29); ctx.lineTo(0, 29+flame); ctx.lineTo(4, 29); ctx.closePath(); ctx.fill();
ctx.fillStyle = '#1e40af';
ctx.beginPath(); ctx.moveTo(-28, 18); ctx.lineTo(-8, -5); ctx.lineTo(-8, 20); ctx.closePath(); ctx.fill();
ctx.beginPath(); ctx.moveTo(28, 18); ctx.lineTo(8, -5); ctx.lineTo(8, 20); ctx.closePath(); ctx.fill();
ctx.fillStyle = player.powerTime>0 ? '#ff00ff' : '#e5e7eb';
ctx.beginPath(); ctx.moveTo(0, -28); ctx.lineTo(-10, 10); ctx.lineTo(-14, 26); ctx.lineTo(14, 26); ctx.lineTo(10, 10); ctx.closePath(); ctx.fill();
ctx.fillStyle = '#00e5ff';
ctx.beginPath(); ctx.ellipse(0, -2, 6, 12, 0, 0, Math.PI*2); ctx.fill();
ctx.restore();
}
function drawEnemy(e){
ctx.save(); ctx.translate(e.x, e.y);
if(e.isBoss){
ctx.fillStyle = '#7c3aed'; ctx.beginPath(); ctx.ellipse(0, 10, 70, 22, 0, 0, Math.PI*2); ctx.fill();
ctx.fillStyle = '#a78bfa'; ctx.beginPath(); ctx.ellipse(0, 10, 50, 16, 0, 0, Math.PI*2); ctx.fill();
ctx.fillStyle = '#00e5ff'; ctx.beginPath(); ctx.arc(0, -5, 28, Math.PI, 0); ctx.fill();
ctx.fillStyle = '#fff'; ctx.beginPath(); ctx.arc(0, -10, 8, 0, Math.PI*2); ctx.fill();
ctx.fillStyle = '#ff0000'; ctx.beginPath(); ctx.arc(-20, 5, 6, 0, Math.PI*2); ctx.fill(); ctx.beginPath(); ctx.arc(20, 5, 6, 0, Math.PI*2); ctx.fill();
for(let i=-2;i<=2;i++){ ctx.fillStyle = (Math.floor(time*5)+i)%2===0 ? '#facc15' : '#ff4444'; ctx.beginPath(); ctx.arc(i*22, 16, 4, 0, Math.PI*2); ctx.fill(); }
ctx.fillStyle = 'rgba(0,0,0,0.6)'; ctx.fillRect(-60, -48, 120, 8);
ctx.fillStyle = '#ff4444'; ctx.fillRect(-60, -48, 120*(e.hp/e.maxHp), 8);
} else if(e.type===0){
ctx.fillStyle = '#9ca3af'; ctx.beginPath(); ctx.ellipse(0, 5, 28, 10, 0, 0, Math.PI*2); ctx.fill();
ctx.fillStyle = '#22c55e'; ctx.beginPath(); ctx.arc(0, -2, 14, Math.PI, 0); ctx.fill();
ctx.fillStyle = '#111'; ctx.beginPath(); ctx.arc(-6, -2, 3, 0, Math.PI*2); ctx.fill(); ctx.beginPath(); ctx.arc(6, -2, 3, 0, Math.PI*2); ctx.fill();
ctx.fillStyle = '#facc15'; ctx.beginPath(); ctx.arc(-18, 8, 3, 0, Math.PI*2); ctx.fill(); ctx.beginPath(); ctx.arc(0, 10, 3, 0, Math.PI*2); ctx.fill(); ctx.beginPath(); ctx.arc(18, 8, 3, 0, Math.PI*2); ctx.fill();
} else if(e.type===1){
ctx.fillStyle = '#22c55e'; ctx.beginPath(); ctx.arc(0, 0, 20, 0, Math.PI*2); ctx.fill();
ctx.fillStyle = '#16a34a'; ctx.beginPath(); ctx.arc(-8, 12, 10, 0, Math.PI*2); ctx.fill(); ctx.beginPath(); ctx.arc(8, 12, 10, 0, Math.PI*2); ctx.fill();
ctx.strokeStyle = '#22c55e'; ctx.lineWidth = 3; ctx.beginPath(); ctx.moveTo(-8,-16); ctx.lineTo(-12,-26); ctx.moveTo(8,-16); ctx.lineTo(12,-26); ctx.stroke();
ctx.fillStyle = '#facc15'; ctx.beginPath(); ctx.arc(-12,-28,4,0,Math.PI*2); ctx.fill(); ctx.beginPath(); ctx.arc(12,-28,4,0,Math.PI*2); ctx.fill();
ctx.fillStyle = '#fff'; ctx.beginPath(); ctx.arc(-7,-2,6,0,Math.PI*2); ctx.fill(); ctx.beginPath(); ctx.arc(7,-2,6,0,Math.PI*2); ctx.fill();
ctx.fillStyle = '#111'; ctx.beginPath(); ctx.arc(-7,-2,3,0,Math.PI*2); ctx.fill(); ctx.beginPath(); ctx.arc(7,-2,3,0,Math.PI*2); ctx.fill();
} else {
ctx.fillStyle = '#ef4444'; ctx.beginPath(); ctx.moveTo(0, 24); ctx.lineTo(-22, -18); ctx.lineTo(22, -18); ctx.closePath(); ctx.fill();
ctx.fillStyle = '#991b1b'; ctx.beginPath(); ctx.moveTo(0, 16); ctx.lineTo(-12, -10); ctx.lineTo(12, -10); ctx.closePath(); ctx.fill();
ctx.fillStyle = '#fff'; ctx.beginPath(); ctx.arc(0, -2, 6, 0, Math.PI*2); ctx.fill();
}
ctx.restore();
}
function spawnEnemy(){
if(gameOver || dialogueActive) return;
if(kills>0 && kills%15===0 && !enemies.some(e=>e.isBoss)){
// قبل الزعيم بيحكي
showDialogue(bossDialogues, ()=>{
enemies.push({ x:450, y:80, w:120, h:60, hp:80, maxHp:80, speed:0.6, type:0, isBoss:true, lastShot:Date.now(), dir:1 });
});
kills++; // عشان ما يضل يعيد الحوار
return;
}
const type = Math.floor(Math.random()*3);
enemies.push({ x: 50 + Math.random()*800, y: -30, w:44, h:40, hp: type===1?3:2, maxHp: type===1?3:2, speed: 1 + Math.random()*1.2 + level*0.2, type, isBoss:false, lastShot: Date.now()+Math.random()*1000, wobble: Math.random()*Math.PI*2 });
}
setInterval(spawnEnemy, 900);
for(let i=0;i<3;i++) setTimeout(spawnEnemy, 2000 + i*600);
function shoot(){
const w = weapons[currentWeapon];
const now = Date.now();
if(now - player.lastShot < w.fireRate) return;
player.lastShot = now; playShoot();
if(w.bullets===1) bullets.push({x:player.x, y:player.y-30, vx:0, vy:-10, damage:1, color:w.color});
else if(w.bullets===2){ bullets.push({x:player.x-12, y:player.y-20, vx:0, vy:-10, damage:1, color:w.color}); bullets.push({x:player.x+12, y:player.y-20, vx:0, vy:-10, damage:1, color:w.color}); }
else { bullets.push({x:player.x, y:player.y-30, vx:0, vy:-10, damage:1, color:w.color}); bullets.push({x:player.x-14, y:player.y-20, vx:-2, vy:-9, damage:1, color:w.color}); bullets.push({x:player.x+14, y:player.y-20, vx:2, vy:-9, damage:1, color:w.color}); }
}
function draw(){
time += 0.016;
if(!gameOver && !dialogueActive){
// تحديث الحركة - السفينة بتميل
let targetTilt = 0;
if(keys['a']||keys['A']||keys['ArrowLeft']){ player.x -= player.speed; targetTilt = -0.3; }
if(keys['d']||keys['D']||keys['ArrowRight']){ player.x += player.speed; targetTilt = 0.3; }
if(keys['w']||keys['W']||keys['ArrowUp']) player.y -= player.speed;
if(keys['s']||keys['S']||keys['ArrowDown']) player.y += player.speed;
if(Math.abs(mouse.x - player.x) > 5){
const diff = mouse.x - player.x;
player.x += diff*0.12;
targetTilt = diff > 0 ? 0.25 : -0.25;
}
player.tilt += (targetTilt - player.tilt)*0.15;
player.x = Math.max(30, Math.min(870, player.x));
player.y = Math.max(300, Math.min(500, player.y));
if(player.powerTime>0) player.powerTime--;
shoot();
}
ctx.fillStyle = '#050510'; ctx.fillRect(0,0,900,540);
const grad = ctx.createRadialGradient(200,100,10,200,100,300);
grad.addColorStop(0,'rgba(168,85,247,0.25)'); grad.addColorStop(1,'rgba(0,0,0,0)');
ctx.fillStyle = grad; ctx.fillRect(0,0,900,540);
stars.forEach(s=>{
if(!dialogueActive) s.y += s.speed;
if(s.y > 540){ s.y = 0; s.x = Math.random()*900; }
ctx.fillStyle = '#fff'; ctx.globalAlpha = 0.3 + Math.sin(time*3 + s.x)*0.4; ctx.fillRect(s.x, s.y, s.s, s.s);
});
ctx.globalAlpha = 1;
if(!dialogueActive){
enemies.forEach(e=>{
if(e.isBoss){
e.x += e.dir*0.8;
if(e.x > 750) e.dir = -1;
if(e.x < 150) e.dir = 1;
e.y = 80 + Math.sin(time*2)*15;
if(Date.now()-e.lastShot > 800){ e.lastShot = Date.now(); for(let i=-1;i<=1;i++) enemyBullets.push({x:e.x+i*25, y:e.y+30, vx:i*1.2, vy:4, damage:10}); }
} else {
e.y += e.speed;
e.x += Math.sin(time*3 + e.wobble)*1.2;
if(Date.now()-e.lastShot > 1600 && e.y > 50 && e.y < 400){ e.lastShot = Date.now(); const ang = Math.atan2(player.y-e.y, player.x-e.x); enemyBullets.push({x:e.x, y:e.y+15, vx:Math.cos(ang)*3.5, vy:Math.sin(ang)*3.5, damage:8}); }
}
if(e.y > 530 && !e.isBoss){ enemies.splice(enemies.indexOf(e),1); player.hp -= 8; updateHUD(); if(player.hp<=0) endGame(); }
});
}
enemies.forEach(drawEnemy);
if(!dialogueActive){
bullets = bullets.filter(b=> b.y > -20);
bullets.forEach(b=>{
b.x += b.vx; b.y += b.vy;
ctx.fillStyle = b.color; ctx.shadowColor = b.color; ctx.shadowBlur = 12; ctx.fillRect(b.x-3, b.y-10, 6, 20); ctx.fillStyle = '#fff'; ctx.fillRect(b.x-1.5, b.y-10, 3, 8); ctx.shadowBlur = 0;
Game Source: هجوم المجرة v2 - تحديث الحوار والحركة
Creator: ChromeFlame24
Libraries: none
Complexity: complex (376 lines, 20.4 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: game-chromeflame24-mwn4bdfk" to link back to the original. Then publish at arcadelab.ai/publish.