Spaces:
Running
Running
<html><head><title>Tank Battle</title><style>body{margin:0;overflow:hidden;background:#333;font-family:Arial}#instructions{position:fixed;top:10px;right:10px;color:#fff;background:rgba(0,0,0,.7);padding:10px;border-radius:5px;z-index:1e3}#weaponInfo{position:fixed;top:150px;right:10px;color:#fff;background:rgba(0,0,0,.7);padding:10px;border-radius:5px;z-index:1e3;font-size:18px}.button{position:fixed;top:50%;left:50%;transform:translate(-50%,-50%);padding:20px 40px;font-size:24px;background:#4caf50;color:#fff;border:none;border-radius:5px;cursor:pointer;display:none;z-index:1e3}#countdown{position:fixed;top:50%;left:50%;transform:translate(-50%,-50%);font-size:72px;color:#fff;text-shadow:2px 2px 4px rgba(0,0,0,.5);z-index:1e3;display:none}</style></head><body><div id="instructions">Controls:<br>WASD - Move tank<br>Mouse - Aim<br>Space - Fire<br>C - Switch Weapon R - Toggle Auto-fire</div><div id="weaponInfo">Current Weapon: Cannon</div><div id="countdown">3</div><button id="nextRound" class="button">Next Round</button><button id="restart" class="button">Restart Game</button><canvas id="gameCanvas"></canvas><script>const _0x4a1a=['width','gameCanvas','cloneNode','mozRequestAnimationFrame','translate','px\x20Arial','round','drawImage','slice','reload','webkitRequestAnimationFrame','createPattern','cannon','currentRound','fillRect','toUpperCase','lastShot','clearRect','angle','getContext','fill','top','none','displayImage','gameOver','charAt','bullet','save','block','beginPath','push','fillText','then','autoFire','rotate','webkitImageSmoothingEnabled','isCountingDown','all','addEventListener','arc','weapons','sin','style','onload','innerHeight','createPattern\x20not\x20supported','mozImageSmoothingEnabled','forEach','speed','filter','sqrt','floor','drawHealthBar','moveTo','height','left','src','onerror','cos','textContent','display','machinegun','play','restore','innerWidth'];(function(_0x2d8f05,_0x4a1a1f){var _0x1d77b9=function(_0x3f9c90){while(--_0x3f9c90){_0x2d8f05['push'](_0x2d8f05['shift']());}};_0x1d77b9(++_0x4a1a1f);}(_0x4a1a,0x1b7));var _0x1d77=function(_0x2d8f05,_0x4a1a1f){_0x2d8f05=_0x2d8f05-0x0;var _0x1d77b9=_0x4a1a[_0x2d8f05];return _0x1d77b9;};const canvas=document.getElementById(_0x1d77('0x1')),ctx=canvas[_0x1d77('0x13')]('2d'),nextRoundBtn=document.getElementById('nextRound'),restartBtn=document.getElementById('restart'),weaponInfo=document.getElementById('weaponInfo'),countdownEl=document.getElementById('countdown');canvas[_0x1d77('0x0')]=window[_0x1d77('0x3f')],canvas[_0x1d77('0x37')]=window[_0x1d77('0x2c')];let currentRound=0x1,gameOver=![],currentWeapon=_0x1d77('0xc'),enemies=[],bullets=[],items=[],lastShot=0x0,isCountingDown=!![],countdownTime=0x3,autoFire=![];const backgroundImg=new Image(),playerImg=new Image(),enemyImg=new Image(),cannonSound=new Audio('firemn.ogg'),machinegunSound=new Audio('firemg.ogg'),enemyFireSound=new Audio('fireenemy.ogg');enemyFireSound['volume']=0.5;const weapons={'cannon':{'fireRate':0x3e8,'damage':0.25,'bulletSize':0x5,'sound':cannonSound},'machinegun':{'fireRate':0xc8,'damage':0.05,'bulletSize':0x2,'sound':machinegunSound}},player={'x':canvas[_0x1d77('0x0')]/0x2,'y':canvas[_0x1d77('0x37')]/0x2,'speed':0x5,'angle':0x0,'width':0x64,'height':0x2d,'health':0x3e8,'maxHealth':0x3e8};function startCountdown(){isCountingDown=!![],countdownTime=0x3,countdownEl[_0x1d77('0x2a')][_0x1d77('0x3e')]='block',countdownEl[_0x1d77('0x3d')]=countdownTime;const _0x3f9c90=setInterval(()=>{countdownTime--,countdownTime<=0x0&&(clearInterval(_0x3f9c90),countdownEl[_0x1d77('0x2a')][_0x1d77('0x3e')]=_0x1d77('0x16')),countdownEl[_0x1d77('0x3d')]=countdownTime>0x0?countdownTime:'GO!';},0x3e8);}class Enemy{constructor(){this['x']=Math['random']()*canvas[_0x1d77('0x0')],this['y']=Math['random']()*canvas[_0x1d77('0x37')],this['health']=0x3e8,this['maxHealth']=0x3e8,this[_0x1d77('0x30')]=0x2,this[_0x1d77('0x10')]=0x0,this['shootInterval']=0x3e8,this[_0x1d77('0x12')]=0x0,this[_0x1d77('0x0')]=0x64,this[_0x1d77('0x37')]=0x2d,this['moveTimer']=0x0,this['moveInterval']=Math['random']()*0x7d0+0x3e8,this['moveAngle']=Math['random']()*Math['PI']*0x2;}['update'](){if(isCountingDown)return;const _0x3f9c90=Date['now']();_0x3f9c90-this['moveTimer']>this['moveInterval']&&(this['moveAngle']=Math['random']()*Math['PI']*0x2,this['moveTimer']=_0x3f9c90),this['x']+=Math[_0x1d77('0x3c')](this['moveAngle'])*this[_0x1d77('0x30')],this['y']+=Math[_0x1d77('0x29')](this['moveAngle'])*this[_0x1d77('0x30')],this['x']=Math['max'](this[_0x1d77('0x0')]/0x2,Math['min'](canvas[_0x1d77('0x0')]-this[_0x1d77('0x0')]/0x2,this['x'])),this['y']=Math['max'](this[_0x1d77('0x37')]/0x2,Math['min'](canvas[_0x1d77('0x37')]-this[_0x1d77('0x37')]/0x2,this['y'])),this[_0x1d77('0x12')]=Math['atan2'](player['y']-this['y'],player['x']-this['x']),_0x3f9c90-this[_0x1d77('0x10')]>this['shootInterval']&&!isCountingDown&&(this['shoot'](),this[_0x1d77('0x10')]=_0x3f9c90);}['shoot'](){enemyFireSound[_0x1d77('0x2')]()[_0x1d77('0x3f')],bullets[_0x1d77('0x1e')]({'x':this['x']+Math[_0x1d77('0x3c')](this[_0x1d77('0x12')])*0x1e,'y':this['y']+Math[_0x1d77('0x29')](this[_0x1d77('0x12')])*0x1e,'angle':this[_0x1d77('0x12')],'speed':0x5,'isEnemy':!![],'size':0x3});}}function initRound(){enemies=[];for(let _0x3f9c90=0x0;_0x3f9c90<0x1*currentRound;_0x3f9c90++){enemies[_0x1d77('0x1e')](new Enemy());}player['health']=player['maxHealth'],bullets=[],items=[],startCountdown();}canvas[_0x1d77('0x26')]('mousemove',_0x3f9c90=>{player[_0x1d77('0x12')]=Math['atan2'](_0x3f9c90['clientY']-player['y'],_0x3f9c90['clientX']-player['x']);});const keys={};document[_0x1d77('0x26')]('keydown',_0x3f9c90=>{keys[_0x3f9c90['key']]=!![],_0x3f9c90['key']['toLowerCase']()==='c'?(currentWeapon=currentWeapon===_0x1d77('0xc')?_0x1d77('0x3f'):_0x1d77('0xc'),weaponInfo[_0x1d77('0x3d')]='Current\x20Weapon:\x20'+currentWeapon[_0x1d77('0x19')](0x0)[_0x1d77('0xf')]()+currentWeapon[_0x1d77('0x8')](0x1)):_0x3f9c90['key']['toLowerCase']()==='r'&&(autoFire=!autoFire);}),document[_0x1d77('0x26')]('keyup',_0x3f9c90=>keys[_0x3f9c90['key']]=![]);function fireBullet(){if(isCountingDown)return;const _0x3f9c90=weapons[currentWeapon],_0x4a1a1f=Date['now']();(keys['\x20']||autoFire)&&_0x4a1a1f-lastShot>_0x3f9c90['fireRate']&&(_0x3f9c90['sound'][_0x1d77('0x2')]()[_0x1d77('0x3f')],bullets[_0x1d77('0x1e')]({'x':player['x']+Math[_0x1d77('0x3c')](player[_0x1d77('0x12')])*0x1e,'y':player['y']+Math[_0x1d77('0x29')](player[_0x1d77('0x12')])*0x1e,'angle':player[_0x1d77('0x12')],'speed':0xa,'isEnemy':![],'damage':_0x3f9c90['damage'],'size':_0x3f9c90['bulletSize']}),lastShot=_0x4a1a1f);}function updateGame(){if(gameOver)return;isCountingDown||(keys['w']&&(player['y']-=player[_0x1d77('0x30')]),keys['s']&&(player['y']+=player[_0x1d77('0x30')]),keys['a']&&(player['x']-=player[_0x1d77('0x30')]),keys['d']&&(player['x']+=player[_0x1d77('0x30')]),player['x']=Math['max'](player[_0x1d77('0x0')]/0x2,Math['min'](canvas[_0x1d77('0x0')]-player[_0x1d77('0x0')]/0x2,player['x'])),player['y']=Math['max'](player[_0x1d77('0x37')]/0x2,Math['min'](canvas[_0x1d77('0x37')]-player[_0x1d77('0x37')]/0x2,player['y'])),fireBullet()),enemies[_0x1d77('0x2f')](_0x3f9c90=>_0x3f9c90['update']()),!isCountingDown&&(bullets=bullets[_0x1d77('0x31')](_0x3f9c90=>{if(_0x3f9c90['x']+=Math[_0x1d77('0x3c')](_0x3f9c90[_0x1d77('0x12')])*_0x3f9c90[_0x1d77('0x30')],_0x3f9c90['y']+=Math[_0x1d77('0x29')](_0x3f9c90[_0x1d77('0x12')])*_0x3f9c90[_0x1d77('0x30')],!_0x3f9c90['isEnemy'])return enemies=enemies[_0x1d77('0x31')](_0x4a1a1f=>{const _0x1d77b9=Math['hypot'](_0x3f9c90['x']-_0x4a1a1f['x'],_0x3f9c90['y']-_0x4a1a1f['y']);return _0x1d77b9<0x1e&&(_0x4a1a1f['health']-=_0x4a1a1f['maxHealth']*_0x3f9c90['damage'],_0x4a1a1f['health']<=0x0?(spawnHealthItem(_0x4a1a1f['x'],_0x4a1a1f['y']),![]):!![]),!![];}),_0x3f9c90['x']>=0x0&&_0x3f9c90['x']<=canvas[_0x1d77('0x0')]&&_0x3f9c90['y']>=0x0&&_0x3f9c90['y']<=canvas[_0x1d77('0x37')];const _0x4a1a1f=Math['hypot'](_0x3f9c90['x']-player['x'],_0x3f9c90['y']-player['y']);return _0x4a1a1f<0x1e?(player['health']-=0x64,player['health']<=0x0&&(gameOver=!![],restartBtn[_0x1d77('0x2a')][_0x1d77('0x3e')]=_0x1d77('0x1c')),![]):_0x3f9c90['x']>=0x0&&_0x3f9c90['x']<=canvas[_0x1 |