cutechicken commited on
Commit
44e9133
·
verified ·
1 Parent(s): c80e234

Update index.html

Browse files
Files changed (1) hide show
  1. index.html +1 -1
index.html CHANGED
@@ -1 +1 @@
1
- <!DOCTYPE html><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
 
1
+ <!DOCTYPE html><html><head><title>TB</title><style>body{margin:0;overflow:hidden;background:#333;font-family:Arial}._a{background-repeat:repeat}._b{position:fixed;color:#fff;background:rgba(0,0,0,.7);border-radius:5px;z-index:1e3}._c{top:10px;right:10px;padding:10px}._d{top:150px;right:10px;padding:10px;font-size:18px}._e{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}._f{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 class="_b _c">Controls:<br>WASD - Move tank<br>Mouse - Aim<br>Space - Fire<br>C - Switch Weapon R - Toggle Auto-fire</div><div class="_b _d" id="_g">Current Weapon: Cannon</div><div class="_f" id="_h">3</div><button class="_e" id="_i">Next Round</button><button class="_e" id="_j">Restart Game</button><canvas id="_k"></canvas><script>(function(){var _0x4ae9=['getContext','width','height','innerWidth','innerHeight','getElementById','_k','_i','_j','_g','_h','city.png','player.png','enemy.png','firemn.ogg','firemg.ogg','fireenemy.ogg'];var _0x5f=function(_0x56b4){return _0x4ae9[_0x56b4]};var _c=document[_0x5f(5)](_0x5f(6));var _ctx=_c[_0x5f(0)]('2d');var _n=document[_0x5f(5)](_0x5f(7));var _r=document[_0x5f(5)](_0x5f(8));var _w=document[_0x5f(5)](_0x5f(9));var _cd=document[_0x5f(5)](_0x5f(10));_c[_0x5f(1)]=window[_0x5f(3)];_c[_0x5f(2)]=window[_0x5f(4)];var _cr=1,_go=!1,_cw='cannon',_e=[],_b=[],_i=[],_ls=0,_ic=!0,_ct=3,_af=!1;var _bg=new Image();_bg.src=_0x5f(11);var _p=new Image();_p.src=_0x5f(12);var _ei=new Image();_ei.src=_0x5f(13);var _cs=new Audio(_0x5f(14));var _ms=new Audio(_0x5f(15));var _es=new Audio(_0x5f(16));_es.volume=.5;var _ws={cannon:{fireRate:1e3,damage:.25,bulletSize:5,sound:_cs},machinegun:{fireRate:200,damage:.05,bulletSize:2,sound:_ms}};var _pl={x:_c[_0x5f(1)]/2,y:_c[_0x5f(2)]/2,speed:5,angle:0,width:100,height:45,health:1e3,maxHealth:1e3};function _sc(){_ic=!0;_ct=3;_cd.style.display='block';_cd.textContent=_ct;var _ci=setInterval(function(){_ct--;if(_ct<=0){clearInterval(_ci);_cd.style.display='none';_ic=!1}_cd.textContent=_ct>0?_ct:'GO!'},1e3)}class _En{constructor(){this.x=Math.random()*_c[_0x5f(1)];this.y=Math.random()*_c[_0x5f(2)];this.health=1e3;this.maxHealth=1e3;this.speed=2;this.lastShot=0;this.shootInterval=1e3;this.angle=0;this.width=100;this.height=45;this.moveTimer=0;this.moveInterval=Math.random()*2e3+1e3;this.moveAngle=Math.random()*Math.PI*2}update(){if(_ic)return;var _n=Date.now();if(_n-this.moveTimer>this.moveInterval){this.moveAngle=Math.random()*Math.PI*2;this.moveTimer=_n}this.x+=Math.cos(this.moveAngle)*this.speed;this.y+=Math.sin(this.moveAngle)*this.speed;this.x=Math.max(this.width/2,Math.min(_c[_0x5f(1)]-this.width/2,this.x));this.y=Math.max(this.height/2,Math.min(_c[_0x5f(2)]-this.height/2,this.y));this.angle=Math.atan2(_pl.y-this.y,_pl.x-this.x);if(_n-this.lastShot>this.shootInterval&&!_ic){this.shoot();this.lastShot=_n}}shoot(){_es.cloneNode().play();_b.push({x:this.x+Math.cos(this.angle)*30,y:this.y+Math.sin(this.angle)*30,angle:this.angle,speed:5,isEnemy:!0,size:3})}}function _ir(){_e=[];for(var i=0;i<1*_cr;i++){_e.push(new _En())}_pl.health=_pl.maxHealth;_b=[];_i=[];_sc()}_c.addEventListener('mousemove',function(e){_pl.angle=Math.atan2(e.clientY-_pl.y,e.clientX-_pl.x)});var _k={};document.addEventListener('keydown',function(e){_k[e.key]=!0;if(e.key.toLowerCase()==='c'){_cw=_cw==='cannon'?'machinegun':'cannon';_w.textContent='Current Weapon: '+_cw.charAt(0).toUpperCase()+_cw.slice(1)}else if(e.key.toLowerCase()==='r'){_af=!_af}});document.addEventListener('keyup',function(e){_k[e.key]=!1});function _fb(){if(_ic)return;var _w=_ws[_cw];var _n=Date.now();if((_k[' ']||_af)&&_n-_ls>_w.fireRate){_w.sound.cloneNode().play();_b.push({x:_pl.x+Math.cos(_pl.angle)*30,y:_pl.y+Math.sin(_pl.angle)*30,angle:_pl.angle,speed:10,isEnemy:!1,damage:_w.damage,size:_w.bulletSize});_ls=_n}}function _ug(){if(_go)return;if(!_ic){if(_k['w'])_pl.y-=_pl.speed;if(_k['s'])_pl.y+=_pl.speed;if(_k['a'])_pl.x-=_pl.speed;if(_k['d'])_pl.x+=_pl.speed;_pl.x=Math.max(_pl.width/2,Math.min(_c[_0x5f(1)]-_pl.width/2,_pl.x));_pl.y=Math.max(_pl.height/2,Math.min(_c[_0x5f(2)]-_pl.height/2,_pl.y));_fb()}_e.forEach(function(e){e.update()});if(!_ic){_b=_b.filter(function(b){b.x+=Math.cos(b.angle)*b.speed;b.y+=Math.sin(b.angle)*b.speed;if(!b.isEnemy){_e=_e.filter(function(e){var d=Math.hypot(b.x-e.x,b.y-e.y);if(d<30){e.health-=e.maxHealth*b.damage;if(e.health<=0){_shi(e.x,e.y);return!1}return!0}return!0})}else{var d=Math.hypot(b.x-_pl.x,b.y-_pl.y);if(d<30){_pl.health-=100;if(_pl.health<=0){_go=!0;_r.style.display='block'}return!1}}return b.x>=0&&b.x<=_c[_0x5f(1)]&&b.y>=0&&b.y<=_c[_0x5f(2)]});_i=_i.filter(function(i){var d=Math.hypot(i.x-_pl.x,i.y-_pl.y);if(d<30){_pl.health=Math.min(_pl.health+200,_pl.maxHealth);return!1}return!0});if(_e.length===0){if(_cr<10){_n.style.display='block'}else{_go=!0;_r.style.display='block'}}}}function _shi(x,y){_i.push({x:x,y:y})}function _dhb(x,y,h,m,w,h,c){_ctx.fillStyle='#333';_ctx.fillRect(x-w/2,y-h/2,w,h);_ctx.fillStyle=c;_ctx.fillRect(x-w/2,y-h/2,w*(h/m),h)}function _dg(){_ctx.clearRect(0,0,_c[_0x5f(1)],_c[_0x5f(2)]);var p=_ctx.createPattern(_bg,'repeat');_ctx.fillStyle=p;_ctx.fillRect(0,0,_c[_0x5f(1)],_c[_0x5f(2)]);_ctx.save();_ctx.translate(_pl.x,_pl.y);_ctx.rotate(_pl.angle);_ctx.drawImage(_p,-_pl.width/2,-_pl.height/2,_pl.width,_pl.height);_ctx.restore();_dhb(_c[_0x5f(1)]/2,30,_pl.health,_pl.maxHealth,200,20,'green');_e.forEach(function(e){_ctx.save();_ctx.translate(e.x,e.y);_ctx.rotate(e.angle);_ctx.drawImage(_ei,-e.width/2,-e.height/2,e.width,e.height);_ctx.restore();_dhb(e.x,e.y-40,e.health,e.maxHealth,60,5,'red')});_b.forEach(function(b){_ctx.beginPath();_ctx.fillStyle=b.isEnemy?'red':'yellow';_ctx.arc(b.x,b.y,b.size,0,Math.PI*2);_ctx.fill()});_i.forEach(function(i){_ctx.beginPath();_ctx.fillStyle='green';_ctx.arc(i.x,i.y,10,0,Math.PI*2);_ctx.fill()});_ctx.fillStyle='white';_ctx.font='24px Arial';_ctx.fillText('Round '+_cr+'/10',10,30);if(_ic){_ctx.fillStyle='rgba(0, 0, 0, 0.5)';_ctx.fillRect(0,0,_c[_0x5f(1)],_c[_0x5f(2)])}}function _gl(){_ug();_dg();requestAnimationFrame(_gl)}_n.addEventListener('click',function(){_cr++;_n.style.display='none';_ir()});_r.addEventListener('click',function(){_cr=1;_go=!1;_r.style.display='none';_ir()});Promise.all([new Promise(function(r){_bg.onload=r}),new Promise(function(r){_p.onload=r}),new Promise(function(r){_ei.onload=r})]).then(function(){_ir();_gl()});window.addEventListener('resize',function(){_c[_0x5f(1)]=window[_0x5f(3)];_c[_0x5f(2)]=window[_0x5f(4)]})})();</script></body></html>