PIXEL TANKS: CHAOS ARENA
by ChromeFlame24362 lines19.5 KB
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<title>PIXEL TANKS: CHAOS ARENA</title>
<style>
*{margin:0;padding:0;box-sizing:border-box;-webkit-tap-highlight-color:transparent}
html,body{width:100%;height:100%;overflow:hidden;background:#08080f;font-family:"Courier New",monospace;color:#fff}
canvas{display:block;image-rendering:pixelated;touch-action:none}
#game{position:fixed;inset:0}
.screen{position:fixed;inset:0;display:flex;align-items:center;justify-content:center;background:linear-gradient(160deg,#0b0b18,#120a24 60%,#08131c);z-index:20}
.panel{width:min(760px,94vw);max-height:94vh;overflow:auto;padding:28px;border:4px solid #2de2ff;border-radius:14px;background:rgba(8,10,20,.94);box-shadow:0 0 45px #2de2ff55, inset 0 0 40px #00000088;text-align:center}
h1{font-size:clamp(28px,7vw,56px);letter-spacing:3px;color:#ffe94a;text-shadow:4px 4px 0 #b029ff,8px 8px 0 #000}
h2{margin:16px 0 8px;color:#2de2ff;letter-spacing:2px}
.sub{color:#9ff;font-size:14px;margin-bottom:20px}
.btn{display:block;width:100%;margin:10px 0;padding:15px;border:3px solid #ffe94a;border-radius:8px;background:#131328;color:#ffe94a;font:bold 19px "Courier New",monospace;letter-spacing:2px;cursor:pointer;transition:.12s}
.btn:hover,.btn:active{background:#ffe94a;color:#0a0a14;transform:translateY(-2px);box-shadow:0 6px 0 #b029ff}
.btn.small{padding:10px;font-size:15px}
.row{display:flex;gap:10px;flex-wrap:wrap}
.row .btn{flex:1}
.mode{border:2px solid #333;border-radius:8px;padding:10px;margin:8px 0;cursor:pointer;background:#101022}
.mode.selected{border-color:#2de2ff;background:#132535;box-shadow:0 0 18px #2de2ff55}
.mode b{color:#ffe94a}
.mode div{font-size:12px;color:#9aa}
.controls{font-size:12px;color:#aaa;line-height:1.7;margin-top:14px;text-align:left}
.kbd{display:inline-block;border:1px solid #555;border-radius:4px;padding:1px 6px;background:#181828;color:#fff}
.hidden{display:none!important}
#hud{position:fixed;inset:0;pointer-events:none;z-index:10;font-family:"Courier New",monospace}
.score{position:absolute;top:10px;padding:8px 14px;border:3px solid #fff;border-radius:8px;background:rgba(0,0,0,.65);font:bold 18px "Courier New",monospace}
#p1Score{left:10px;border-color:#3aff6e;color:#3aff6e}
#p2Score{right:10px;border-color:#ff4d6d;color:#ff4d6d}
#centerMsg{position:absolute;top:42%;left:50%;transform:translate(-50%,-50%);font-size:clamp(24px,7vw,54px);font-weight:bold;color:#ffe94a;text-shadow:4px 4px 0 #b029ff,8px 8px 0 #000;opacity:0;transition:.2s}
#modeLabel{position:absolute;top:64px;left:50%;transform:translateX(-50%);font-size:13px;color:#2de2ff;background:rgba(0,0,0,.5);padding:5px 12px;border-radius:6px}
#pauseBtn{position:absolute;bottom:14px;right:14px;pointer-events:auto;padding:10px 16px;border:3px solid #fff;border-radius:8px;background:rgba(0,0,0,.6);color:#fff;font:bold 15px "Courier New",monospace;cursor:pointer}
.stick{position:fixed;bottom:20px;width:130px;height:130px;border:3px solid #ffffff44;border-radius:50%;background:rgba(255,255,255,.06);z-index:15;display:none}
.knob{position:absolute;left:50%;top:50%;width:54px;height:54px;margin:-27px;border-radius:50%;background:#ffffff33;border:3px solid #fff}
#leftStick{left:18px}#rightStick{right:18px}
</style>
</head>
<body>
<canvas id="game"></canvas>
<div id="hud" class="hidden">
<div id="p1Score" class="score">P1 0</div>
<div id="p2Score" class="score">P2 0</div>
<div id="modeLabel">CLASSIC DEATHMATCH</div>
<div id="centerMsg"></div>
<button id="pauseBtn">II PAUSE</button>
</div>
<div id="menu" class="screen">
<div class="panel">
<h1>PIXEL TANKS</h1>
<div class="sub">CHAOS ARENA</div>
<button class="btn" onclick="showModes()">▶ PLAY</button>
<button class="btn" onclick="startGame('survival')">☠ SURVIVAL</button>
<button class="btn" onclick="startGame('koth')">👑 KING OF THE HILL</button>
<button class="btn" onclick="startGame('royale')">🌀 BATTLE ROYALE</button>
<div class="controls">
<b>P1:</b> <span class="kbd">W A S D</span> move • <span class="kbd">SPACE</span> shoot<br>
<b>P2:</b> <span class="kbd">ARROWS</span> move • <span class="kbd">ENTER</span> shoot<br>
<b>Mobile:</b> Left stick moves • Right stick shoots<br>
<b>Bullets bounce up to 5 times.</b> One hit = elimination.
</div>
</div>
</div>
<div id="modes" class="screen hidden">
<div class="panel">
<h2>SELECT MODE</h2>
<div class="mode selected" data-mode="classic" onclick="selectMode(this)"><b>CLASSIC DEATHMATCH</b><div>1v1 or versus bots • First to 10 kills</div></div>
<div class="mode" data-mode="team" onclick="selectMode(this)"><b>TEAM BATTLE 2v2</b><div>Blue team versus Red team</div></div>
<div class="mode" data-mode="survival" onclick="selectMode(this)"><b>SURVIVAL</b><div>Survive 20 escalating AI waves</div></div>
<div class="mode" data-mode="koth" onclick="selectMode(this)"><b>KING OF THE HILL</b><div>Control the glowing zone</div></div>
<div class="mode" data-mode="royale" onclick="selectMode(this)"><b>BATTLE ROYALE</b><div>The maze shrinks over time</div></div>
<h2>OPPONENTS</h2>
<div class="row">
<button class="btn small" onclick="setBots(0)">NO BOTS</button>
<button class="btn small" onclick="setBots(1)">1 BOT</button>
<button class="btn small" onclick="setBots(2)">2 BOTS</button>
<button class="btn small" onclick="setBots(3)">3 BOTS</button>
</div>
<h2>BOT DIFFICULTY</h2>
<div class="row">
<button class="btn small" onclick="setDifficulty(0)">EASY</button>
<button class="btn small" onclick="setDifficulty(1)">NORMAL</button>
<button class="btn small" onclick="setDifficulty(2)">INSANE</button>
</div>
<button class="btn" onclick="startGame(selectedMode)">START BATTLE</button>
<button class="btn small" onclick="backToMenu()">BACK</button>
</div>
</div>
<div id="pause" class="screen hidden">
<div class="panel">
<h2>PAUSED</h2>
<button class="btn" onclick="resumeGame()">RESUME</button>
<button class="btn small" onclick="restartGame()">RESTART</button>
<button class="btn small" onclick="quitToMenu()">MAIN MENU</button>
</div>
</div>
<div id="result" class="screen hidden">
<div class="panel">
<h2 id="resultTitle">VICTORY!</h2>
<div id="resultText" class="sub"></div>
<button class="btn" onclick="restartGame()">⚡ QUICK REMATCH</button>
<button class="btn small" onclick="quitToMenu()">MAIN MENU</button>
</div>
</div>
<div id="leftStick" class="stick"><div class="knob"></div></div>
<div id="rightStick" class="stick"><div class="knob"></div></div>
<script>
const cvs=document.getElementById('game'),ctx=cvs.getContext('2d');
let W=0,H=0,cell=42,cols=25,rows=16,maze=[],state='menu',mode='classic',botCount=1,difficulty=1;
let tanks=[],bullets=[],particles=[],powerups=[],walls=[],zone=null,zoneTimer=0,shake=0,slowmo=0,roundTime=60,royaleTimer=0,wave=1,waveTimer=0,teamScores={blue:0,red:0},lastTime=0,raf=null;
const keys={},mobile={left:{x:0,y:0,active:false},right:{x:0,y:0,active:false}};
const skins=[
{name:'CLASSIC GREEN',body:'#3aff6e',dark:'#1d8f3d',turret:'#eaffea'},
{name:'NEON CYBER',body:'#2de2ff',dark:'#0d7a9c',turret:'#eaffff'},
{name:'GOLDEN KING',body:'#ffe94a',dark:'#a87800',turret:'#fffbe0'},
{name:'ZOMBIE',body:'#8ce86b',dark:'#3f6b2e',turret:'#d8ffd0'},
{name:'SAMURAI',body:'#ff4d6d',dark:'#8a1b31',turret:'#ffd8de'},
{name:'GALAXY',body:'#b029ff',dark:'#5c0d8a',turret:'#f2d8ff'}
];
const powerTypes=['triple','laser','shield','speed','ghost','big','mine','invis','magnet'];
function resize(){W=innerWidth;H=innerHeight;cvs.width=W;cvs.height=H;cell=Math.max(28,Math.min(48,Math.floor(Math.min(W/25,H/16))));cols=Math.max(15,Math.floor(W/cell));rows=Math.max(11,Math.floor(H/cell));}
addEventListener('resize',resize);resize();
function showModes(){document.getElementById('menu').classList.add('hidden');document.getElementById('modes').classList.remove('hidden');}
function backToMenu(){document.getElementById('modes').classList.add('hidden');document.getElementById('menu').classList.remove('hidden');}
function selectMode(el){document.querySelectorAll('.mode').forEach(m=>m.classList.remove('selected'));el.classList.add('selected');selectedMode=el.dataset.mode;}
let selectedMode='classic';
function setBots(n){botCount=n;}
function setDifficulty(n){difficulty=n;}
function generateMaze(){
maze=Array.from({length:rows},()=>Array(cols).fill(0));
for(let y=0;y<rows;y++)for(let x=0;x<cols;x++)if(x===0||y===0||x===cols-1||y===rows-1)maze[y][x]=1;
for(let y=2;y<rows-2;y+=2)for(let x=2;x<cols-2;x+=2){
maze[y][x]=1;
if(Math.random()<.72){const dirs=[[0,1],[1,0],[0,-1],[-1,0]];const d=dirs[Math.floor(Math.random()*4)];const nx=x+d[0],ny=y+d[1];if(nx>0&&ny>0&&nx<cols-1&&ny<rows-1)maze[ny][nx]=1;}
}
for(let i=0;i<Math.floor(cols*rows*.04);i++){const x=1+Math.floor(Math.random()*(cols-2)),y=1+Math.floor(Math.random()*(rows-2));maze[y][x]=1;}
maze[1][1]=0;maze[rows-2][cols-2]=0;maze[1][cols-2]=0;maze[rows-2][1]=0;
walls=[];
for(let y=0;y<rows;y++)for(let x=0;x<cols;x++)if(maze[y][x])walls.push({x:x*cell,y:y*cell,w:cell,h:cell,crack:0});
}
function solid(px,py,r=10){
for(const w of walls)if(px+r>w.x&&px-r<w.x+w.w&&py+r>w.y&&py-r<w.y+w.h)return true;
return false;
}
function freeSpot(){
let x,y;do{x=cell*1.5+Math.random()*(W-cell*3);y=cell*1.5+Math.random()*(H-cell*3);}while(solid(x,y,18));return{x,y};
}
class Tank{
constructor(x,y,skin,team,controller){
this.x=x;this.y=y;this.angle=0;this.skin=skin;this.team=team;this.controller=controller;
this.alive=true;this.cooldown=0;this.speed=2.35;this.size=15;this.bounces=5;
this.power=null;this.powerTime=0;this.shield=0;this.invis=0;this.ghost=0;this.kills=0;this.deaths=0;this.streak=0;this.isBot=controller==='bot';this.fireHeld=false;this.mineCooldown=0;
}
update(dt){
if(!this.alive)return;
let mx=0,my=0,shoot=false;
if(this.controller==='p1'){mx=(keys['d']?1:0)-(keys['a']?1:0);my=(keys['s']?1:0)-(keys['w']?1:0);shoot=keys[' '];}
else if(this.controller==='p2'){mx=(keys['ArrowRight']?1:0)-(keys['ArrowLeft']?1:0);my=(keys['ArrowDown']?1:0)-(keys['ArrowUp']?1:0);shoot=keys['Enter'];}
else if(this.controller==='mobile'){mx=mobile.left.x;my=mobile.left.y;shoot=mobile.right.active&&Math.hypot(mobile.right.x,mobile.right.y)>.35;if(shoot)this.angle=Math.atan2(mobile.right.y,mobile.right.x);}
else this.botThink();
if(this.controller!=='mobile'&&(mx||my))this.angle=Math.atan2(my,mx);
const spd=this.power==='speed'?this.speed*1.65:this.speed;
const nx=this.x+Math.cos(this.angle)*spd*(mx||my?1:0),ny=this.y+Math.sin(this.angle)*spd*(my||mx?1:0);
if(!solid(nx,this.y,13))this.x=nx;
if(!solid(this.x,ny,13))this.y=ny;
this.cooldown-=dt;this.powerTime-=dt;this.shield-=dt;this.invis-=dt;this.ghost-=dt;this.mineCooldown-=dt;
if(this.powerTime<=0){this.power=null;this.bounces=5;}
if(shoot&&this.cooldown<=0)this.shoot();
}
botThink(){
const target=tanks.find(t=>t!==this&&t.alive&&(mode!=='team'||t.team!==this.team));
if(!target)return;
const dx=target.x-this.x,dy=target.y-this.y,dist=Math.hypot(dx,dy);
const desired=Math.atan2(dy,dx);
let diff=desired-this.angle;while(diff>Math.PI)diff-=Math.PI*2;while(diff<-Math.PI)diff+=Math.PI*2;
const turn=difficulty===0?.045:difficulty===1?.09:.16;
this.angle+=Math.max(-turn,Math.min(turn,diff));
const aheadX=this.x+Math.cos(this.angle)*24,aheadY=this.y+Math.sin(this.angle)*24;
if(!solid(aheadX,aheadY,13)){this.x+=Math.cos(this.angle)*this.speed;this.y+=Math.sin(this.angle)*this.speed;}
else this.angle+=(Math.random()<.5?.12:-.12);
if(dist<340&&Math.abs(diff)<.28&&this.cooldown<=0)this.shoot();
}
shoot(){
this.cooldown=this.power==='triple'?.42:.62;
const angles=this.power==='triple'?[-.18,0,.18]:[0];
const speed=this.power==='big'?9:8.4;
for(const off of angles){
const a=this.angle+off;
bullets.push({x:this.x+Math.cos(a)*18,y:this.y+Math.sin(a)*18,vx:Math.cos(a)*speed,vy:Math.sin(a)*speed,bounces:this.bounces,owner:this,r:this.power==='big'?7:4,life:5200,laser:false,magnet:false});
}
if(this.power==='laser'){
let lx=this.x,ly=this.y;const dx=Math.cos(this.angle),dy=Math.sin(this.angle);
for(let i=0;i<160;i++){lx+=dx*6;ly+=dy*6;if(solid(lx,ly,2))break;for(const t of tanks)if(t!==this&&t.alive&&Math.hypot(t.x-lx,t.y-ly)<16)killTank(t,this);}
for(let i=0;i<28;i++)particles.push({x:this.x+dx*(20+i*8),y:this.y+dy*(20+i*8),vx:0,vy:0,life:12,color:'#ff4d6d',size:3});
}
if(this.power==='mine'&&this.mineCooldown<=0){this.mineCooldown=1.2;bullets.push({x:this.x,y:this.y,vx:0,vy:0,bounces:0,owner:this,r:9,life:9000,mine:true});}
sfx('shoot');shake=Math.max(shake,3);
for(let i=0;i<8;i++)particles.push({x:this.x+Math.cos(this.angle)*20,y:this.y+Math.sin(this.angle)*20,vx:Math.cos(this.angle)*3+Math.random()*2-1,vy:Math.sin(this.angle)*3+Math.random()*2-1,life:14,color:'#ffe94a',size:3});
}
}
function spawnTank(controller,team,skinIndex){
const p=freeSpot();const t=new Tank(p.x,p.y,skins[skinIndex%skins.length],team,controller);tanks.push(t);return t;
}
function killTank(t,killer){
if(!t.alive)return;t.alive=false;t.deaths++;explode(t.x,t.y,t.skin.body);
if(killer&&killer!==t){killer.kills++;killer.streak++;
if(killer.streak===2)announce('DOUBLE KILL!');
else if(killer.streak===3)announce('TRIPLE KILL!');
else if(killer.streak>=4)announce('RAMPAGE!');
if(mode==='classic'&&killer.kills>=10)endMatch(killer.controller==='bot'?'BOT WINS':'PLAYER 1 WINS');
if(mode==='team'){killer.team==='blue'?teamScores.blue++:teamScores.red++;if(teamScores.blue>=10||teamScores.red>=10)endMatch(teamScores.blue>=10?'BLUE TEAM WINS':'RED TEAM WINS');}
}
if(mode==='survival'&&t.controller==='p1')endMatch('GAME OVER');
slowmo=mode==='classic'?45:0;shake=14;sfx('explosion');
setTimeout(()=>{if(state==='playing'){const p=freeSpot();t.x=p.x;t.y=p.y;t.alive=true;t.shield=90;t.streak=0;}},mode==='survival'?1200:900);
}
function explode(x,y,color){
for(let i=0;i<42;i++){const a=Math.random()*Math.PI*2,s=1+Math.random()*6;particles.push({x,y,vx:Math.cos(a)*s,vy:Math.sin(a)*s,life:20+Math.random()*20,color:i%3?color:'#ffe94a',size:2+Math.random()*4});}
}
function announce(text){const el=document.getElementById('centerMsg');el.textContent=text;el.style.opacity=1;setTimeout(()=>el.style.opacity=0,900);}
function spawnPowerup(){
if(powerups.length>3)return;const p=freeSpot();powerups.push({x:p.x,y:p.y,type:powerTypes[Math.floor(Math.random()*powerTypes.length)],life:16000});
}
function collectPowerup(t,p){
t.power=p.type;t.powerTime=8000;t.bounces=p.type==='big'?3:5;
if(p.type==='shield')t.shield=8000;
if(p.type==='ghost')t.ghost=5000;
if(p.type==='invis')t.invis=6000;
announce(t.controller==='p1'?'POWER: '+p.type.toUpperCase():'');sfx('power');
}
function bulletWallCollision(b){
for(const w of walls){
if(b.x+b.r>w.x&&b.x-b.r<w.x+w.w&&b.y+b.r>w.y&&b.y-b.r<w.y+w.h){
if(b.owner.ghost>0)return;
const overlapL=b.x+b.r-w.x,overlapR=w.x+w.w-(b.x-b.r),overlapT=b.y+b.r-w.y,overlapB=w.y+w.h-(b.y-b.r);
const m=Math.min(overlapL,overlapR,overlapT,overlapB);
if(m===overlapL){b.x=w.x-b.r;b.vx*=-1;}
else if(m===overlapR){b.x=w.x+w.w+b.r;b.vx*=-1;}
else if(m===overlapT){b.y=w.y-b.r;b.vy*=-1;}
else{b.y=w.y+w.h+b.r;b.vy*=-1;}
b.bounces--;w.crack=8;sfx('bounce');
for(let i=0;i<5;i++)particles.push({x:b.x,y:b.y,vx:Math.random()*3-1.5,vy:Math.random()*3-1.5,life:10,color:'#fff',size:2});
return b.bounces<=0;
}
}
return false;
}
function update(dt){
if(state!=='playing')return;
const scale=slowmo>0?.35:1;slowmo-=dt;
for(const t of tanks)t.update(dt*scale);
for(let i=bullets.length-1;i>=0;i--){
const b=bullets[i];b.x+=b.vx*dt*scale;b.y+=b.vy*dt*scale;b.life-=dt;
if(b.life<=0){bullets.splice(i,1);continue;}
if(bulletWallCollision(b)){bullets.splice(i,1);continue;}
if(b.mine){
for(const t of tanks)if(t.alive&&t!==b.owner&&Math.hypot(t.x-b.x,t.y-b.y)<20){explode(b.x,b.y,'#ff4d6d');killTank(t,b.owner);bullets.splice(i,1);break;}
continue;
}
for(const t of tanks){
if(!t.alive||t===b.owner)continue;
if(mode==='team'&&t.team===b.owner.team)continue;
if(Math.hypot(t.x-b.x,t.y-b.y)<t.size+b.r){
if(t.shield>0){t.shield=0;explode(b.x,b.y,'#2de2ff');}
else killTank(t,b.owner);
bullets.splice(i,1);break;
}
}
}
for(let i=particles.length-1;i>=0;i--){const p=particles[i];p.x+=p.vx;p.y+=p.vy;p.vx*=.92;p.vy*=.92;p.life--;if(p.life<=0)particles.splice(i,1);}
for(let i=powerups.length-1;i>=0;i--){
const p=powerups[i];p.life-=dt;
for(const t of tanks)if(t.alive&&Math.hypot(t.x-p.x,t.y-p.y)<26){collectPowerup(t,p);powerups.splice(i,1);break;}
if(p.life<=0)powerups.splice(i,1);
}
if(Math.random()<.006)spawnPowerup();
if(mode==='koth'){
if(!zone){const p=freeSpot();zone={x:p.x,y:p.y,r:75};}
for(const t of tanks)if(t.alive&&Math.hypot(t.x-zone.x,t.y-zone.y)<zone.r){
if(t.controller==='p1'){teamScores.blue+=dt*.001;document.getElementById('p1Score').textContent='P1 '+Math.floor(teamScores.blue);}
else if(t.controller==='p2'){teamScores.red+=dt*.001;document.getElementById('p2Score').textContent='P2 '+Math.floor(teamScores.red);}
if(Math.floor(teamScores.blue)>=30)endMatch('BLUE WINS');
if(Math.floor(teamScores.red)>=30)endMatch('RED WINS');
}
}
if(mode==='royale'){
royaleTimer+=dt;
if(royaleTimer>5000){
royaleTimer=0;const margin=cell;
for(const w of walls)if(w.x<margin||w.y<margin||w.x+w.w>W-margin||w.y+w.h>H-margin)w.crack=10;
for(const t of tanks)if(t.alive&&(t.x<margin||t.y<margin||t.x>W-margin||t.y>H-margin))killTank(t,null);
announce('THE ARENA SHRINKS!');
}
}
if(mode==='survival'){
waveTimer-=dt;
if(waveTimer<=0){
wave++;waveTimer=18000;announce('WAVE '+wave+'!');
if(wave<=20){const count=Math.min(2+Math.floor(wave/3),7);for(let i=0;i<count;i++)spawnTank('bot',i%2?'red':'blue',Math.floor(Math.random()*skins.length));}
else endMatch('YOU SURVIVED ALL 20 WAVES!');
}
}
if(shake>0)shake*=.88;
updateHUD();
}
function updateHUD(){
document.getElementById('p1Score').textContent='P1 '+tanks[0].kills;
document.getElementById('p2Score').textContent=(tanks[1]?tanks[1].kills:0)+' BOT';
}
function drawTank(t){
if(!t.alive)return;
ctx.save();ctx.translate(t.x,t.y);ctx.rotate(t.angle);
if(t.invis>0)ctx.globalAlpha=.25;
ctx.fillStyle=t.skin.dark;ctx.fillRect(-15,-12,30,24);
ctx.fillStyle=t.skin.body;ctx.fillRect(-13,-10,26,20);
ctx.fillStyle='#111';ctx.fillRect(-8,-8,16,16);
ctx.fillStyle=t.skin.turret;ctx.fillRect(0,-4,24,8);
ctx.fillStyle='#000';ctx.fillRect(20,-3,5,6);
if(t.shield>0){ctx.strokeStyle='#2de2ff';ctx.lineWidth=3;ctx.beginPath();ctx.arc(0,0,23,0,Math.PI*2);ctx.stroke();}
ctx.restore();
if(t.ghost>0){ctx.globalAlpha=.5;ctx.fillStyle='#b029ff';ctx.fillRect(t.x-15,t.y-12,30,24);ctx.globalAlpha=1;}
}
function draw(){
ctx.fillStyle='#08080f';ctx.fillRect(0,0,W,H);
const sx=shake?(Math.random()-.5)*shake:0,sy=shake?(Math.random()-.5)*shake:0;
ctx.save();ctx.translate(sx,sy);
for(const w of walls){
ctx.fillStyle=w.crack>0?'#4b3b52':'#22223a';ctx.fillRect(w.x,w.y,w.w,w.h);
ctx.fillStyle=w.crack>0?'#6d5468':'#2f2f4d';ctx.fillRect(w.x+3,w.y+3,w.w-6,w.h-6);
if(w.crack>0){w.crack--;ctx.strokeStyle='#000';ctx.beginPath();ctx.moveTo(w.x+4,w.y+4);ctx.lineTo(w.x+w.w-4,w.y+w.h-4);ctx.stroke();}
}
if(zone&&mode==='koth'){
ctx.fillStyle='rgba(255,233,74,.18)';ctx.beginPath();ctx.arc(zone.x,zone.y,zone.r,0,Math.PI*2);ctx.fill();
ctx.strokeStyle='#ffe94a';ctx.lineWidth=4;ctx.stroke();
}
for(const p of powerups){
const colors={triple:'#ffe94a',laser:'#ff4d6d',shield:'#2de2ff',speed:'#3aff6e',ghost:'#b029ff',big:'#ff8c42',mine:'#ff4d6d',invis:'#9aa',magnet:'#b029ff'};
ctx.fillStyle=colors[p.type]||'#fff';ctx.fillRect(p.x-9,Game Source: PIXEL TANKS: CHAOS ARENA
Creator: ChromeFlame24
Libraries: none
Complexity: complex (362 lines, 19.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: pixel-tanks-chaos-arena-chromeflame24" to link back to the original. Then publish at arcadelab.ai/publish.