🎮ArcadeLab

云阙战纪|手游轻量版

by TurboGlider56
591 lines19.4 KB
▶ Play
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<title>云阙战纪|手游轻量版</title>
<style>
*{margin:0;padding:0;box-sizing:border-box;font-family:system-ui, sans-serif;-webkit-tap-highlight-color:transparent;}
html,body{background:#0f1419;color:#fff;height:100%;overflow:hidden;}
#game{background:#223322;width:100vw;height:100vh;display:block;}
.info{position:fixed;top:4px;left:0;right:0;text-align:center;line-height:1.2;font-size:11px;z-index:10;color:#eee}
.panel{position:fixed;top:20px;left:4px;display:flex;gap:3px;z-index:10;flex-wrap:wrap;max-width:90vw}
.box{background:#223344;padding:3px 5px;border-radius:4px;border:1px solid #5588cc;font-size:11px}
.box.selected{background:#2277bb;border-color:#88bbff}
.shop{position:fixed;top:44px;right:4px;background:rgba(20,30,45,0.9);padding:6px;border-radius:6px;border:1px solid #58a;z-index:10;font-size:11px;max-width:145px}
.shop-item{padding:2px;margin:2px;background:#334455}
.hidden{display:none}
</style>
</head>
<body>
<div class="info">轻量版|左摇杆移动,右侧普攻/1技能/大招/回城,B商店</div>
<div class="panel" id="heroPanel">
  <div class="box selected" data-hero="lingshi">灵师【水】</div>
  <div class="box" data-hero="yinren">隐刃【风】</div>
  <div class="box" data-hero="yuwei">御卫【土】</div>
</div>
<div class="shop hidden" id="shop">
  <div><b>装备商店</b></div>
  <div class="shop-item" data-item="magic">灵法玉 60金|法强+8</div>
  <div class="shop-item" data-item="attack">破锋刃 60金|攻击+7</div>
  <div class="shop-item" data-item="armor">玄岩甲 60金|护甲+10</div>
  <div class="shop-item" data-item="cd">流云佩 80金|冷却缩减18%</div>
</div>
<canvas id="game"></canvas>

<script>
const canvas = document.getElementById('game');
const ctx = canvas.getContext('2d');
function resizeCanvas(){
  canvas.width = window.innerWidth;
  canvas.height = window.innerHeight;
}
resizeCanvas();
window.addEventListener('resize',resizeCanvas);
const W = ()=>canvas.width;
const H = ()=>canvas.height;
const shop = document.getElementById("shop");
let heroType = "lingshi";

// ========= 虚拟摇杆 =========
class Joystick{
  constructor(){
    this.radius = 70;
    this.knobR = 28;
    this.baseX = 90;
    this.baseY = H()-90;
    this.active = false;
    this.touchId = null;
    this.dx = 0;
    this.dy = 0;
  }
  reset(){this.active=false;this.touchId=null;this.dx=0;this.dy=0;}
  touchStart(t){
    const dist = Math.hypot(t.clientX - this.baseX, t.clientY - this.baseY);
    if(dist < this.radius){
      this.active=true;
      this.touchId = t.identifier;
      this.update(t.clientX,t.clientY);
    }
  }
  touchMove(t){
    if(t.identifier !== this.touchId) return;
    this.update(t.clientX,t.clientY);
  }
  touchEnd(t){
    if(t.identifier === this.touchId) this.reset();
  }
  update(x,y){
    let dx = x - this.baseX;
    let dy = y - this.baseY;
    let len = Math.hypot(dx,dy);
    if(len>this.radius){dx = dx/len*this.radius; dy = dy/len*this.radius;}
    this.dx = dx/this.radius;
    this.dy = dy/this.radius;
  }
  draw(){
    ctx.beginPath();
    ctx.arc(this.baseX,this.baseY,this.radius,0,Math.PI*2);
    ctx.fillStyle="rgba(255,255,255,0.2)";ctx.fill();
    const kx = this.baseX + this.dx*this.radius;
    const ky = this.baseY + this.dy*this.radius;
    ctx.beginPath();
    ctx.arc(kx,ky,this.knobR,0,Math.PI*2);
    ctx.fillStyle="rgba(255,255,255,0.55)";ctx.fill();
  }
}
const joy = new Joystick();

// 右侧技能按钮
const touchBtns = [
  {name:"普攻",r:40,x:W()-66,y:H()-66,press:false,id:"atk"},
  {name:"1",r:36,x:W()-132,y:H()-66,press:false,id:"skill1"},
  {name:"大招",r:40,x:W()-66,y:H()-132,press:false,id:"skill2"},
  {name:"回城",r:32,x:W()-132,y:H()-132,press:false,id:"recall"},
];
function hitBtn(px,py){
  for(let b of touchBtns){
    if(Math.hypot(px-b.x,py-b.y) < b.r) return b;
  }
  return null;
}

//元素克制
const elementCounter = {wind:"wood", wood:"water", water:"fire", fire:"earth", earth:"thunder", thunder:"wind"};
const elementDmgBonus = 0.15;

//英雄配置
const heroConfig = {
  lingshi:{hp:90,atk:14,speed:2.0,color:"#7cf",elem:"water",skill1Dmg:1.8, skill2Dmg:0.8, skill2Slow:true},
  yinren:{hp:75,atk:19,speed:2.6,color:"#fd8",elem:"wind",skill1Dmg:2.2, skill2Dmg:1.0},
  yuwei:{hp:140,atk:9,speed:1.7,color:"#7a7",elem:"earth",skill1Dmg:1.3, skill2Dmg:0.6, skill2Stun:true}
}

//玩家
let player = {x:100,y:H()/2,w:34,h:34,hp:100,maxHp:100,atk:12,speed:2.2,cd1:0,cd2:0,gold:0,armor:0,cdr:0,team:1,
buff:{wind:0,rock:0,red:0,blue:0},dead:false,respawnTimer:0,recall:false,recallTimer:0,elem:"water",stun:0,slow:0};

//AI敌方(精简为2个AI,减少运算)
let aiHeroes = [
  {x:W()-120,y:H()*0.25,w:34,h:34,hp:90,maxHp:90,atk:13,speed:1.9,team:2,elem:"fire",cd1:0,cd2:0,stun:0,slow:0},
  {x:W()-120,y:H()*0.75,w:34,h:34,hp:72,maxHp:72,atk:18,speed:2.4,team:2,elem:"thunder",cd1:0,cd2:0,stun:0,slow:0},
];

let towers = [
  {x:340,y:H()*0.2,team:1,hp:200,range:140},
  {x:340,y:H()*0.8,team:1,hp:200,range:140},
  {x:W()-340,y:H()*0.2,team:2,hp:200,range:140},
  {x:W()-340,y:H()*0.8,team:2,hp:200,range:140},
];
let coreBlue = {x:60,y:H()/2,team:1,hp:450};
let coreRed = {x:W()-60,y:H()/2,team:2,hp:450};

let minions = [];
let projectiles = [];
let monsters = [];
let gameOver = false;
let winText = "";
let damageTexts = [];
// 移除粒子数组,完全关闭粒子特效,大幅减负

//草丛
const grassZones = [
  {x:120,y:80,w:110,h:90},
  {x:120,y:H()-170,w:110,h:90},
  {x:W()-230,y:80,w:110,h:90},
  {x:W()-230,y:H()-170,w:110,h:90},
];
function inGrass(obj){
  for(let g of grassZones){
    if(obj.x>g.x && obj.x<g.x+g.w && obj.y>g.y && obj.y<g.y+g.h) return true;
  }
  return false;
}

//英雄选择
document.querySelectorAll(".box").forEach(b=>{
  b.onclick = ()=>{
    document.querySelectorAll(".box").forEach(i=>i.classList.remove("selected"));
    b.classList.add("selected");
    heroType = b.dataset.hero;
    const cfg = heroConfig[heroType];
    player.hp = cfg.hp; player.maxHp = cfg.hp;
    player.atk = cfg.atk; player.speed = cfg.speed;
    player.elem = cfg.elem;
  }
})
window.addEventListener("keydown",e=>{
  if(e.code === "KeyB") shop.classList.toggle("hidden");
  if(e.code === "KeyR" && !player.dead) player.recall=true;
})
document.querySelectorAll(".shop-item").forEach(it=>{
  it.onclick = ()=>{
    const item = it.dataset.item;
    if(item==="magic" && player.gold>=60){player.gold-=60;player.atk+=8}
    if(item==="attack" && player.gold>=60){player.gold-=60;player.atk+=7}
    if(item==="armor" && player.gold>=60){player.gold-=60;player.armor+=10}
    if(item==="cd" && player.gold>=80){player.gold-=80;player.cdr+=0.18}
  }
})

function spawnMinion(team){
  const lanes = [H()*0.2, H()*0.8];
  lanes.forEach(y=>{
    const sx = team===1 ? 80 : W()-80;
    minions.push({x:sx,y:y,w:24,h:24,hp:48,maxHp:48,atk:6,speed:team===1?0.7:-0.7,team,elem:"thunder",stun:0,slow:0});
  })
}
function spawnWild(){
  monsters.push({x:240,y:140,w:28,h:28,hp:70,maxHp:70,atk:5,gold:18,name:"灵鹿",team:0,elem:"wood"});
  monsters.push({x:W()-240,y:H()-140,w:28,h:28,hp:70,maxHp:70,atk:5,gold:18,name:"灵鹿",team:0,elem:"wood"});
  monsters.push({x:W()*0.22, H()*0.5, w:32,h:32,hp:110,maxHp:110,atk:7,gold:32,name:"红BUFF",team:0,elem:"fire",isRedBuff:true});
  monsters.push({x:W()*0.78, H()*0.5, w:32,h:32,hp:110,maxHp:110,atk:7,gold:32,name:"蓝BUFF",team:0,elem:"water",isBlueBuff:true});
}
function spawnDragon(){
  monsters.push({x:W()/2,y:H()/2,w:44,h:44,hp:220,maxHp:220,atk:10,gold:60,name:"渊龙",team:0,isDragon:true,elem:"water"})
}
setInterval(()=>spawnMinion(1),7500);
setInterval(()=>spawnMinion(2),7500);
setInterval(()=>{
  monsters = monsters.filter(m=>m.hp>0);
  const normal = monsters.filter(x=>!x.isDragon && !x.isRedBuff && !x.isBlueBuff);
  if(normal.length<2) spawnWild();
},14000)
setInterval(()=>{
  const hasDragon = monsters.some(m=>m.isDragon);
  if(!hasDragon) spawnDragon();
},240000)
spawnMinion(1);spawnMinion(2);
spawnWild();

//触摸事件
canvas.addEventListener("touchstart",(e)=>{
  e.preventDefault();
  for(let t of e.changedTouches){
    const btn = hitBtn(t.clientX,t.clientY);
    if(btn){
      btn.press=true;
      if(btn.id==="atk"){
        let dmg = getElementDmg(player.elem,"unknown",player.atk + (player.buff.red>0 ? 4 :0));
        projectiles.push({x:player.x+player.w/2,y:player.y+player.h/2,tx:t.clientX,ty:t.clientY,speed:7,dmg:dmg,team:1,attackerElem:player.elem});
      }
      if(btn.id==="skill1" && player.cd1<=0){
        player.cd1 = 45*(1-player.cdr)*(player.buff.blue>0?0.75:1);
        const cfg = heroConfig[heroType];
        let dmg = getElementDmg(player.elem,"unknown",player.atk * cfg.skill1Dmg);
        projectiles.push({x:player.x+player.w/2,y:player.y+player.h/2,tx:t.clientX,ty:t.clientY,speed:9,dmg:dmg,team:1,color:cfg.color,attackerElem:player.elem});
      }
      if(btn.id==="skill2" && player.cd2<=0){
        player.cd2 = 120*(1-player.cdr)*(player.buff.blue>0?0.75:1);
        const cfg = heroConfig[heroType];
        for(let a=0;a<Math.PI*2;a+=0.45){
          let dmg = getElementDmg(player.elem,"unknown",player.atk * cfg.skill2Dmg);
          projectiles.push({
            x:player.x+player.w/2,y:player.y+player.h/2,
            tx:player.x+player.w/2+Math.cos(a)*120,
            ty:player.y+player.w/2+Math.sin(a)*120,
            speed:6,dmg:dmg,team:1,color:"#0ff",attackerElem:player.elem,
            slow:cfg.skill2Slow, stun:cfg.skill2Stun
          })
        }
      }
      if(btn.id==="recall" && !player.dead) player.recall=true;
    }else{
      joy.touchStart(t);
    }
  }
})
canvas.addEventListener("touchmove",(e)=>{
  e.preventDefault();
  for(let t of e.changedTouches){
    joy.touchMove(t);
  }
})
canvas.addEventListener("touchend",(e)=>{
  e.preventDefault();
  for(let t of e.changedTouches){
    joy.touchEnd(t);
    const btn = hitBtn(t.clientX,t.clientY);
    if(btn) btn.press=false;
  }
})
canvas.addEventListener("touchcancel",(e)=>{
  e.preventDefault();
  for(let t of e.changedTouches){
    joy.touchEnd(t);
    const btn = hitBtn(t.clientX,t.clientY);
    if(btn) btn.press=false;
  }
})

function dist(a,b){return Math.hypot(a.x-b.x,a.y-b.y)}
function getElementDmg(attackerElem,targetElem,baseDmg){
  if(elementCounter[attackerElem] === targetElem) return baseDmg*(1+elementDmgBonus);
  if(elementCounter[targetElem] === attackerElem) return baseDmg*(1-elementDmgBonus);
  return baseDmg;
}
function addDamageText(x,y,num,color="#ff4444"){
  damageTexts.push({x,y,num,color,life:50});
}

function update(){
  if(gameOver)return;
  //buff计时
  if(player.buff.wind>0) player.buff.wind--;
  if(player.buff.red>0) player.buff.red--;
  if(player.buff.blue>0) player.buff.blue--;
  if(player.stun>0) player.stun--;
  if(player.slow>0) player.slow--;

  if(player.dead){
    player.respawnTimer--;
    if(player.respawnTimer <=0){
      player.dead=false;
      player.hp = player.maxHp;
      player.x=100;player.y=H()/2;
    }
    return;
  }
  //回城
  if(player.recall){
    player.recallTimer++;
    if(player.recallTimer>120){
      player.x=100;player.y=H()/2;
      player.recall=false;player.recallTimer=0;
    }
    if(joy.dx!==0 || joy.dy!==0){
      player.recall=false;player.recallTimer=0;
    }
  }
  //玩家移动
  let spd = player.speed;
  if(player.slow>0) spd *=0.6;
  if(player.buff.wind>0) spd *=1.25;
  if(!player.recall && player.stun<=0){
    player.x += joy.dx * spd;
    player.y += joy.dy * spd;
  }
  player.x = Math.max(0,Math.min(W()-player.w,player.x));
  player.y = Math.max(0,Math.min(H()-player.h,player.y));

  let cdMult = 1-player.cdr;
  if(player.buff.blue>0) cdMult *=0.75;
  if(player.cd1>0)player.cd1 -= cdMult;
  if(player.cd2>0)player.cd2 -= cdMult;

  //AI英雄(减少2个AI,降低计算压力)
  aiHeroes.forEach(ai=>{
    if(ai.hp<=0) return;
    if(ai.stun>0) ai.stun--;
    if(ai.slow>0) ai.slow--;
    if(ai.cd1>0) ai.cd1--;
    if(ai.cd2>0) ai.cd2--;
    let target=null;
    if(dist(ai,player)<220 && !inGrass(player)) target=player;
    if(!target){
      for(let m of minions){if(m.team!==ai.team && dist(ai,m)<160){target=m;break}}
    }
    if(!target){
      for(let t of towers){if(t.team!==ai.team && dist(ai,t)<220){target=t;break}}
    }
    if(!target) target = coreBlue;

    let aiSpd = ai.speed;
    if(ai.slow>0) aiSpd *=0.6;
    if(target && dist(ai,target)>70 && ai.stun<=0){
      const ang = Math.atan2(target.y-ai.y,target.x-ai.x);
      ai.x += Math.cos(ang)*aiSpd;
      ai.y += Math.sin(ang)*aiSpd;
    }
    if(target && dist(ai,target)<110 && Math.random()<0.025){
      let dmg = getElementDmg(ai.elem, target.elem||"unknown", ai.atk);
      if(target.armor) dmg *= (1-target.armor*0.01);
      target.hp -= dmg;
      addDamageText(target.x+target.w/2,target.y,Math.floor(dmg),"#ff6666");
    }
    if(target && dist(ai,target)<160 && ai.cd1<=0 && Math.random()<0.006){
      ai.cd1=50;
      let dmg = getElementDmg(ai.elem, target.elem||"unknown", ai.atk*1.6);
      projectiles.push({x:ai.x+ai.w/2,y:ai.y+ai.h/2,tx:target.x,ty:target.y,speed:8,dmg:dmg,team:2,color:"#f66",attackerElem:ai.elem});
    }
  })

  //小兵
  for(let i=minions.length-1;i>=0;i--){
    const m = minions[i];
    if(m.stun>0) m.stun--;
    if(m.slow>0) m.slow--;
    let target=null;
    for(let o of minions){if(o.team!==m.team && dist(m,o)<80){target=o;break}}
    if(!target){
      for(let t of towers){if(t.team!==m.team && dist(m,t)<190){target=t;break}}
    }
    if(!target) target = m.team===1 ? coreRed : coreBlue;
    let minSpd = Math.abs(m.speed);
    if(m.slow>0) minSpd *=0.6;
    if(target && dist(m,target)>38 && m.stun<=0){
      const ang = Math.atan2(target.y-m.y,target.x-m.x);
      m.x += Math.cos(ang)*minSpd;
      m.y += Math.sin(ang)*minSpd;
    }else if(target && dist(m,target)<40){
      let dmg = getElementDmg(m.elem, target.elem||"unknown", m.atk*0.025);
      if(target.armor) dmg *= (1-target.armor*0.01);
      target.hp -= dmg;
    }
    if(m.hp<=0){
      if(m.team===2) player.gold += 8;
      minions.splice(i,1);continue;
    }
  }

  //野怪
  for(let i=monsters.length-1;i>=0;i--){
    const m = monsters[i];
    let target=null;
    if(dist(m,player)<130) target=player;
    if(target){
      const ang = Math.atan2(target.y-m.y,target.x-m.x);
      m.x += Math.cos(ang)*0.45;
      m.y += Math.sin(ang)*0.45;
      if(dist(m,target)<36 && Math.random()<0.025){
        let dmg = getElementDmg(m.elem, player.elem, m.atk);
        dmg *= (1-player.armor*0.01);
        player.hp -= dmg;
        addDamageText(player.x+player.w/2,player.y,Math.floor(dmg),"#ff4444");
      }
    }
    if(m.hp<=0){
      player.gold += m.gold;
      if(m.isDragon) player.buff.wind = 600;
      if(m.isRedBuff) player.buff.red = 600;
      if(m.isBlueBuff) player.buff.blue = 600;
      monsters.splice(i,1);continue;
    }
  }

  //弹道
  for(let i=projectiles.length-1;i>=0;i--){
    const p = projectiles[i];
    const ang = Math.atan2(p.ty-p.y,p.tx-p.x);
    p.x += Math.cos(ang)*p.speed;
    p.y += Math.sin(ang)*p.speed;
    let hit = false;
    for(let m of minions){
      if(m.team!==p.team && dist(p,m)<28){
        let dmg = getElementDmg(p.attackerElem, m.elem, p.dmg);
        m.hp -= dmg; hit=true;
        addDamageText(m.x+m.w/2,m.y,Math.floor(dmg),"#ffdd55");
        if(p.slow) m.slow=90;
        if(p.stun) m.stun=60;
        if(m.hp<=0 && m.team===2) player.gold += 8;
        break;
      }
    }
    if(!hit){
      for(let m of monsters){
        if(dist(p,m)<30){
          let dmg = getElementDmg(p.attackerElem, m.elem, p.dmg);
          m.hp -= dmg; hit=true;
          addDamageText(m.x+m.w/2,m.y,Math.floor(dmg),"#ffdd55");
          break;
        }
      }
    }
    if(!hit){
      for(let ai of aiHeroes){
        if(ai.hp>0 && ai.team!==p.team && dist(p,ai)<30){
          let dmg = getElementDmg(p.attackerElem, ai.elem, p.dmg);
          ai.hp -= dmg; hit=true;
          addDamageText(ai.x+ai.w/2,ai.y,Math.floor(dmg),"#ff4444");
          if(p.slow) ai.slow=90;
          if(p.stun) ai.stun=60;
          if(ai.hp<=0) player.gold += 35;
          break;
        }
      }
    }
    if(!hit){
      const enemyCore = p.team===1 ? coreRed : coreBlue;
      if(dist(p,enemyCore)<48){
        enemyCore.hp -= p.dmg; hit=true;
        addDamageText(enemyCore.x,enemyCore.y,Math.floor(p.dmg),"#ff2222");
      }
    }
    if(hit || p.x<0||p.x>W()||p.y<0||p.y>H()) projectiles.splice(i,1);
  }

  //防御塔攻击
  towers.forEach(t=>{
    if(t.hp<=0)return;
    let target=null;
    for(let m of minions){
      if(m.team!==t.team && dist(t,m)<t.range){target=m;break}
    }
    if(!target && t.team===2 && dist(t,player)<t.range) target=player;
    if(target && Math.random()<0.028){
      let dmg =9;
      if(target.armor) dmg *= (1-target.armor*0.01);
      target.hp -=dmg;
      addDamageText(target.x+target.w/2,target.y,Math.floor(dmg),"#ff8888");
    }
  })

  if(player.hp <=0 && !player.dead){
    player.dead = true;
    player.respawnTimer = 180;
  }
  if(coreRed.hp <=0){gameOver=true;winText="🎉胜利!摧毁敌方云阙主殿";}
  if(coreBlue.hp <=0){gameOver=true;winText="💀失败,我方水晶被摧毁";}

  minions = minions.filter(m=>m.hp>0);
  towers = towers.filter(t=>t.hp>0);
  monsters = monsters.filter(m=>m.hp>0);
  aiHeroes = aiHeroes.filter(a=>a.hp>0);

  //飘字更新
  for(let i=damageTexts.length-1;i>=0;i--){
    const dt = damageTexts[i];
    dt.y -= 1;
    dt.life--;
    if(dt.life <=0) damageTexts.splice(i,1);
  }
}

function draw(){
  ctx.fillStyle="#243224";
  ctx.fillRect(0,0,W(),H());
  //草丛
  grassZones.forEach(g=>{
    ctx.fillStyle="#365036";
    ctx.fillRect(g.x,g.y,g.w,g.h);
  })
  //兵线道路
  ctx.fillStyle="#3c3c3c";
  ctx.fillRect(0,H()*0.18,W(),48);
  ctx.fillRect(0,H()*0.78,W(),48);
  //河道
  ctx.fillStyle="#284058";
  ctx.fillRect(W()*0.38, H()*0.38, W()*0.24, H()*0.24);

  //水晶
  ctx.fillStyle="#3388ff";
  ctx.beginPath();ctx.arc(coreBlue.x,coreBlue.y,34,0,Math.PI*2);ctx.fill();
  ctx.fillStyle="#ff4444";
  ctx.beginPath();ctx.arc(coreRed.x,coreRed.y,34,0,Math.PI*2);ctx.fill();

  //塔
  towers.forEach(t=>{
    ctx.fillStyle = t.team===1 ? "#2688bb" : "#bb3333";
    ctx.fillRect(t.x-22,t.y-22,44,44);
  })

  //野怪
  monsters.forEach(m=>{
    if(m.isRedBuff) ctx.fillStyle="#ff4444";
    else if(m.isBlueBuff) ctx.fillStyle="#4488ff";
    else if(m.isDragon) ctx.fillStyle="#cc9922";
    else ctx.fillStyle="#8b7";
    ctx.fillRect(m.x,m.y,m.w,m.h);
    ctx.fillStyle="#222";
    ctx.fillRect(m.x,m.y-6,m.w,4);
    ctx.fillStyle="#0f0";
    ctx.fillRect(m.x,m.y-6,m.w*(m.hp/m.maxHp),4);
  })

  //小兵
  minions.forEach(m=>{
    ctx.fillStyle = m.team===1 ? "#5af" : "#f55";
    ctx.fillRect(m.x,m.y,m.w,m.h);
    ctx.fillStyle="#222";
    ctx.fillRect(m.x,m.y-5,m.w,3);
    ctx.fillStyle="#0f0";
    ctx.fillRect(m.x,m.y-5,m.w*(m.hp/m.maxHp),3);
  })

  //敌方AI
  aiHeroes.forEach(ai=>{
    ctx.fillStyle="#f37";
    ctx.fillRect(ai.x,ai.y,ai.w,ai.h);
    ctx.fillStyle="#222";
    ctx.fillRect(ai.x,ai.y-7,ai.w,5);
    ctx.fillStyle="#0f0";
    ctx.fillRect(ai.x,ai.y-7,ai.w*(ai.hp/ai.maxHp),5);
  })

  //弹道
  projectiles.forEach(p=>{
    ctx.fillStyle = p.color || "#fff";
    ctx.beginPath();ctx.arc(p.x,p.y,4,0,Math.PI*2);ctx.fill();
  })

  //玩家
  const heroColor = heroConfig[heroType].color;
  ctx.fillStyle=heroColor;
  if(!player.dead) ctx.fillRect(player.x,player.y,player.w,player.h);
  if(player.recall){
    ctx.fillStyle="#fff";
    ctx.font="11px sans-serif";
    ctx.fillText("回城",player.x,player.y-10);
  }
  ctx.fillStyle="#222";
  ctx.fillRect(player.x,player.y-7,player.w,5)...

Game Source: 云阙战纪|手游轻量版

Creator: TurboGlider56

Libraries: none

Complexity: complex (591 lines, 19.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-turboglider56" to link back to the original. Then publish at arcadelab.ai/publish.