Spaces:
Running
Running
Update index.html
Browse files- index.html +1 -386
index.html
CHANGED
@@ -1,386 +1 @@
|
|
1 |
-
<!DOCTYPE html>
|
2 |
-
<html>
|
3 |
-
<head>
|
4 |
-
<title>Tank Battle</title>
|
5 |
-
<style>
|
6 |
-
body {
|
7 |
-
margin: 0;
|
8 |
-
overflow: hidden;
|
9 |
-
background: #333;
|
10 |
-
font-family: Arial;
|
11 |
-
}
|
12 |
-
#gameCanvas {
|
13 |
-
background-repeat: repeat;
|
14 |
-
}
|
15 |
-
#instructions {
|
16 |
-
position: fixed;
|
17 |
-
top: 10px;
|
18 |
-
right: 10px;
|
19 |
-
color: white;
|
20 |
-
background: rgba(0,0,0,0.7);
|
21 |
-
padding: 10px;
|
22 |
-
border-radius: 5px;
|
23 |
-
z-index: 1000;
|
24 |
-
}
|
25 |
-
#weaponInfo {
|
26 |
-
position: fixed;
|
27 |
-
top: 150px;
|
28 |
-
right: 10px;
|
29 |
-
color: white;
|
30 |
-
background: rgba(0,0,0,0.7);
|
31 |
-
padding: 10px;
|
32 |
-
border-radius: 5px;
|
33 |
-
z-index: 1000;
|
34 |
-
font-size: 18px;
|
35 |
-
}
|
36 |
-
.button {
|
37 |
-
position: fixed;
|
38 |
-
top: 50%;
|
39 |
-
left: 50%;
|
40 |
-
transform: translate(-50%, -50%);
|
41 |
-
padding: 20px 40px;
|
42 |
-
font-size: 24px;
|
43 |
-
background: #4CAF50;
|
44 |
-
color: white;
|
45 |
-
border: none;
|
46 |
-
border-radius: 5px;
|
47 |
-
cursor: pointer;
|
48 |
-
display: none;
|
49 |
-
z-index: 1000;
|
50 |
-
}
|
51 |
-
#countdown {
|
52 |
-
position: fixed;
|
53 |
-
top: 50%;
|
54 |
-
left: 50%;
|
55 |
-
transform: translate(-50%, -50%);
|
56 |
-
font-size: 72px;
|
57 |
-
color: white;
|
58 |
-
text-shadow: 2px 2px 4px rgba(0,0,0,0.5);
|
59 |
-
z-index: 1000;
|
60 |
-
display: none;
|
61 |
-
}
|
62 |
-
</style>
|
63 |
-
</head>
|
64 |
-
<body>
|
65 |
-
<div id="instructions">
|
66 |
-
Controls:<br>
|
67 |
-
WASD - Move tank<br>
|
68 |
-
Mouse - Aim<br>
|
69 |
-
Space - Fire<br>
|
70 |
-
C - Switch Weapon
|
71 |
-
R - Toggle Auto-fire
|
72 |
-
</div>
|
73 |
-
<div id="weaponInfo">Current Weapon: Cannon</div>
|
74 |
-
<div id="countdown">3</div>
|
75 |
-
<button id="nextRound" class="button">Next Round</button>
|
76 |
-
<button id="restart" class="button">Restart Game</button>
|
77 |
-
<canvas id="gameCanvas"></canvas>
|
78 |
-
|
79 |
-
<script>
|
80 |
-
const canvas = document.getElementById('gameCanvas');
|
81 |
-
const ctx = canvas.getContext('2d');
|
82 |
-
const nextRoundBtn = document.getElementById('nextRound');
|
83 |
-
const restartBtn = document.getElementById('restart');
|
84 |
-
const weaponInfo = document.getElementById('weaponInfo');
|
85 |
-
const countdownEl = document.getElementById('countdown');
|
86 |
-
canvas.width = window.innerWidth;
|
87 |
-
canvas.height = window.innerHeight;
|
88 |
-
// Game state
|
89 |
-
let currentRound = 1;
|
90 |
-
let gameOver = false;
|
91 |
-
let currentWeapon = 'cannon';
|
92 |
-
let enemies = [];
|
93 |
-
let bullets = [];
|
94 |
-
let items = [];
|
95 |
-
let lastShot = 0;
|
96 |
-
let isCountingDown = true;
|
97 |
-
let countdownTime = 3;
|
98 |
-
let autoFire = false;
|
99 |
-
|
100 |
-
// Load assets
|
101 |
-
const backgroundImg = new Image();
|
102 |
-
backgroundImg.src = 'city.png';
|
103 |
-
const playerImg = new Image();
|
104 |
-
playerImg.src = 'player.png';
|
105 |
-
|
106 |
-
const enemyImg = new Image();
|
107 |
-
enemyImg.src = 'enemy.png';
|
108 |
-
// Audio setup
|
109 |
-
const cannonSound = new Audio('firemn.ogg');
|
110 |
-
const machinegunSound = new Audio('firemg.ogg');
|
111 |
-
const enemyFireSound = new Audio('fireenemy.ogg');
|
112 |
-
enemyFireSound.volume = 0.5;
|
113 |
-
const weapons = {
|
114 |
-
cannon: {
|
115 |
-
fireRate: 1000,
|
116 |
-
damage: 0.25,
|
117 |
-
bulletSize: 5,
|
118 |
-
sound: cannonSound
|
119 |
-
},
|
120 |
-
machinegun: {
|
121 |
-
fireRate: 200,
|
122 |
-
damage: 0.05,
|
123 |
-
bulletSize: 2,
|
124 |
-
sound: machinegunSound
|
125 |
-
}
|
126 |
-
};
|
127 |
-
// Player setup
|
128 |
-
const player = {
|
129 |
-
x: canvas.width/2,
|
130 |
-
y: canvas.height/2,
|
131 |
-
speed: 5,
|
132 |
-
angle: 0,
|
133 |
-
width: 100,
|
134 |
-
height: 45,
|
135 |
-
health: 1000,
|
136 |
-
maxHealth: 1000
|
137 |
-
};
|
138 |
-
function startCountdown() {
|
139 |
-
isCountingDown = true;
|
140 |
-
countdownTime = 3;
|
141 |
-
countdownEl.style.display = 'block';
|
142 |
-
countdownEl.textContent = countdownTime;
|
143 |
-
const countInterval = setInterval(() => {
|
144 |
-
countdownTime--;
|
145 |
-
if(countdownTime <= 0) {
|
146 |
-
clearInterval(countInterval);
|
147 |
-
countdownEl.style.display = 'none';
|
148 |
-
isCountingDown = false;
|
149 |
-
}
|
150 |
-
countdownEl.textContent = countdownTime > 0 ? countdownTime : 'GO!';
|
151 |
-
}, 1000);
|
152 |
-
}
|
153 |
-
class Enemy {
|
154 |
-
constructor() {
|
155 |
-
this.x = Math.random() * canvas.width;
|
156 |
-
this.y = Math.random() * canvas.height;
|
157 |
-
this.health = 1000;
|
158 |
-
this.maxHealth = 1000;
|
159 |
-
this.speed = 2;
|
160 |
-
this.lastShot = 0;
|
161 |
-
this.shootInterval = 1000;
|
162 |
-
this.angle = 0;
|
163 |
-
this.width = 100;
|
164 |
-
this.height = 45;
|
165 |
-
this.moveTimer = 0;
|
166 |
-
this.moveInterval = Math.random() * 2000 + 1000;
|
167 |
-
this.moveAngle = Math.random() * Math.PI * 2;
|
168 |
-
}
|
169 |
-
update() {
|
170 |
-
if(isCountingDown) return;
|
171 |
-
const now = Date.now();
|
172 |
-
|
173 |
-
// Movement
|
174 |
-
if (now - this.moveTimer > this.moveInterval) {
|
175 |
-
this.moveAngle = Math.random() * Math.PI * 2;
|
176 |
-
this.moveTimer = now;
|
177 |
-
}
|
178 |
-
this.x += Math.cos(this.moveAngle) * this.speed;
|
179 |
-
this.y += Math.sin(this.moveAngle) * this.speed;
|
180 |
-
// Bounds check
|
181 |
-
this.x = Math.max(this.width/2, Math.min(canvas.width - this.width/2, this.x));
|
182 |
-
this.y = Math.max(this.height/2, Math.min(canvas.height - this.height/2, this.y));
|
183 |
-
// Aim at player
|
184 |
-
this.angle = Math.atan2(player.y - this.y, player.x - this.x);
|
185 |
-
// Shooting
|
186 |
-
if (now - this.lastShot > this.shootInterval && !isCountingDown) {
|
187 |
-
this.shoot();
|
188 |
-
this.lastShot = now;
|
189 |
-
}
|
190 |
-
}
|
191 |
-
shoot() {
|
192 |
-
enemyFireSound.cloneNode().play();
|
193 |
-
bullets.push({
|
194 |
-
x: this.x + Math.cos(this.angle) * 30,
|
195 |
-
y: this.y + Math.sin(this.angle) * 30,
|
196 |
-
angle: this.angle,
|
197 |
-
speed: 5,
|
198 |
-
isEnemy: true,
|
199 |
-
size: 3
|
200 |
-
});
|
201 |
-
}
|
202 |
-
}
|
203 |
-
function initRound() {
|
204 |
-
enemies = [];
|
205 |
-
for(let i = 0; i < 1 * currentRound; i++) {
|
206 |
-
enemies.push(new Enemy());
|
207 |
-
}
|
208 |
-
player.health = player.maxHealth;
|
209 |
-
bullets = [];
|
210 |
-
items = [];
|
211 |
-
startCountdown();
|
212 |
-
}
|
213 |
-
canvas.addEventListener('mousemove', (e) => {
|
214 |
-
player.angle = Math.atan2(e.clientY - player.y, e.clientX - player.x);
|
215 |
-
});
|
216 |
-
const keys = {};
|
217 |
-
document.addEventListener('keydown', e => {
|
218 |
-
keys[e.key] = true;
|
219 |
-
if(e.key.toLowerCase() === 'c') {
|
220 |
-
currentWeapon = currentWeapon === 'cannon' ? 'machinegun' : 'cannon';
|
221 |
-
weaponInfo.textContent = `Current Weapon: ${currentWeapon.charAt(0).toUpperCase() + currentWeapon.slice(1)}`;
|
222 |
-
} else if(e.key.toLowerCase() === 'r') {
|
223 |
-
autoFire = !autoFire;
|
224 |
-
}
|
225 |
-
});
|
226 |
-
document.addEventListener('keyup', e => keys[e.key] = false);
|
227 |
-
function fireBullet() {
|
228 |
-
if(isCountingDown) return;
|
229 |
-
const weapon = weapons[currentWeapon];
|
230 |
-
const now = Date.now();
|
231 |
-
if ((keys[' '] || autoFire) && now - lastShot > weapon.fireRate) {
|
232 |
-
weapon.sound.cloneNode().play();
|
233 |
-
bullets.push({
|
234 |
-
x: player.x + Math.cos(player.angle) * 30,
|
235 |
-
y: player.y + Math.sin(player.angle) * 30,
|
236 |
-
angle: player.angle,
|
237 |
-
speed: 10,
|
238 |
-
isEnemy: false,
|
239 |
-
damage: weapon.damage,
|
240 |
-
size: weapon.bulletSize
|
241 |
-
});
|
242 |
-
lastShot = now;
|
243 |
-
}
|
244 |
-
}
|
245 |
-
function updateGame() {
|
246 |
-
if(gameOver) return;
|
247 |
-
if(!isCountingDown) {
|
248 |
-
if(keys['w']) player.y -= player.speed;
|
249 |
-
if(keys['s']) player.y += player.speed;
|
250 |
-
if(keys['a']) player.x -= player.speed;
|
251 |
-
if(keys['d']) player.x += player.speed;
|
252 |
-
player.x = Math.max(player.width/2, Math.min(canvas.width - player.width/2, player.x));
|
253 |
-
player.y = Math.max(player.height/2, Math.min(canvas.height - player.height/2, player.y));
|
254 |
-
fireBullet();
|
255 |
-
}
|
256 |
-
enemies.forEach(enemy => enemy.update());
|
257 |
-
if(!isCountingDown) {
|
258 |
-
// Update bullets and collisions
|
259 |
-
bullets = bullets.filter(bullet => {
|
260 |
-
bullet.x += Math.cos(bullet.angle) * bullet.speed;
|
261 |
-
bullet.y += Math.sin(bullet.angle) * bullet.speed;
|
262 |
-
if(!bullet.isEnemy) {
|
263 |
-
enemies = enemies.filter(enemy => {
|
264 |
-
const dist = Math.hypot(bullet.x - enemy.x, bullet.y - enemy.y);
|
265 |
-
if(dist < 30) {
|
266 |
-
enemy.health -= enemy.maxHealth * bullet.damage;
|
267 |
-
if(enemy.health <= 0) {
|
268 |
-
spawnHealthItem(enemy.x, enemy.y);
|
269 |
-
return false;
|
270 |
-
}
|
271 |
-
return true;
|
272 |
-
}
|
273 |
-
return true;
|
274 |
-
});
|
275 |
-
} else {
|
276 |
-
const dist = Math.hypot(bullet.x - player.x, bullet.y - player.y);
|
277 |
-
if(dist < 30) {
|
278 |
-
player.health -= 100;
|
279 |
-
if(player.health <= 0) {
|
280 |
-
gameOver = true;
|
281 |
-
restartBtn.style.display = 'block';
|
282 |
-
}
|
283 |
-
return false;
|
284 |
-
}
|
285 |
-
}
|
286 |
-
return bullet.x >= 0 && bullet.x <= canvas.width &&
|
287 |
-
bullet.y >= 0 && bullet.y <= canvas.height;
|
288 |
-
});
|
289 |
-
items = items.filter(item => {
|
290 |
-
const dist = Math.hypot(item.x - player.x, item.y - player.y);
|
291 |
-
if(dist < 30) {
|
292 |
-
player.health = Math.min(player.health + 200, player.maxHealth);
|
293 |
-
return false;
|
294 |
-
}
|
295 |
-
return true;
|
296 |
-
});
|
297 |
-
if(enemies.length === 0) {
|
298 |
-
if(currentRound < 10) {
|
299 |
-
nextRoundBtn.style.display = 'block';
|
300 |
-
} else {
|
301 |
-
gameOver = true;
|
302 |
-
restartBtn.style.display = 'block';
|
303 |
-
}
|
304 |
-
}
|
305 |
-
}
|
306 |
-
}
|
307 |
-
function spawnHealthItem(x, y) {
|
308 |
-
items.push({x, y});
|
309 |
-
}
|
310 |
-
function drawHealthBar(x, y, health, maxHealth, width, height, color) {
|
311 |
-
ctx.fillStyle = '#333';
|
312 |
-
ctx.fillRect(x - width/2, y - height/2, width, height);
|
313 |
-
ctx.fillStyle = color;
|
314 |
-
ctx.fillRect(x - width/2, y - height/2, width * (health/maxHealth), height);
|
315 |
-
}
|
316 |
-
function drawGame() {
|
317 |
-
ctx.clearRect(0, 0, canvas.width, canvas.height);
|
318 |
-
const pattern = ctx.createPattern(backgroundImg, 'repeat');
|
319 |
-
ctx.fillStyle = pattern;
|
320 |
-
ctx.fillRect(0, 0, canvas.width, canvas.height);
|
321 |
-
// Draw all game objects
|
322 |
-
ctx.save();
|
323 |
-
ctx.translate(player.x, player.y);
|
324 |
-
ctx.rotate(player.angle);
|
325 |
-
ctx.drawImage(playerImg, -player.width/2, -player.height/2, player.width, player.height);
|
326 |
-
ctx.restore();
|
327 |
-
drawHealthBar(canvas.width/2, 30, player.health, player.maxHealth, 200, 20, 'green');
|
328 |
-
enemies.forEach(enemy => {
|
329 |
-
ctx.save();
|
330 |
-
ctx.translate(enemy.x, enemy.y);
|
331 |
-
ctx.rotate(enemy.angle);
|
332 |
-
ctx.drawImage(enemyImg, -enemy.width/2, -enemy.height/2, enemy.width, enemy.height);
|
333 |
-
ctx.restore();
|
334 |
-
drawHealthBar(enemy.x, enemy.y - 40, enemy.health, enemy.maxHealth, 60, 5, 'red');
|
335 |
-
});
|
336 |
-
bullets.forEach(bullet => {
|
337 |
-
ctx.beginPath();
|
338 |
-
ctx.fillStyle = bullet.isEnemy ? 'red' : 'yellow';
|
339 |
-
ctx.arc(bullet.x, bullet.y, bullet.size, 0, Math.PI * 2);
|
340 |
-
ctx.fill();
|
341 |
-
});
|
342 |
-
items.forEach(item => {
|
343 |
-
ctx.beginPath();
|
344 |
-
ctx.fillStyle = 'green';
|
345 |
-
ctx.arc(item.x, item.y, 10, 0, Math.PI * 2);
|
346 |
-
ctx.fill();
|
347 |
-
});
|
348 |
-
ctx.fillStyle = 'white';
|
349 |
-
ctx.font = '24px Arial';
|
350 |
-
ctx.fillText(`Round ${currentRound}/10`, 10, 30);
|
351 |
-
if(isCountingDown) {
|
352 |
-
ctx.fillStyle = 'rgba(0, 0, 0, 0.5)';
|
353 |
-
ctx.fillRect(0, 0, canvas.width, canvas.height);
|
354 |
-
}
|
355 |
-
}
|
356 |
-
function gameLoop() {
|
357 |
-
updateGame();
|
358 |
-
drawGame();
|
359 |
-
requestAnimationFrame(gameLoop);
|
360 |
-
}
|
361 |
-
nextRoundBtn.addEventListener('click', () => {
|
362 |
-
currentRound++;
|
363 |
-
nextRoundBtn.style.display = 'none';
|
364 |
-
initRound();
|
365 |
-
});
|
366 |
-
restartBtn.addEventListener('click', () => {
|
367 |
-
currentRound = 1;
|
368 |
-
gameOver = false;
|
369 |
-
restartBtn.style.display = 'none';
|
370 |
-
initRound();
|
371 |
-
});
|
372 |
-
Promise.all([
|
373 |
-
new Promise(resolve => backgroundImg.onload = resolve),
|
374 |
-
new Promise(resolve => playerImg.onload = resolve),
|
375 |
-
new Promise(resolve => enemyImg.onload = resolve)
|
376 |
-
]).then(() => {
|
377 |
-
initRound();
|
378 |
-
gameLoop();
|
379 |
-
});
|
380 |
-
window.addEventListener('resize', () => {
|
381 |
-
canvas.width = window.innerWidth;
|
382 |
-
canvas.height = window.innerHeight;
|
383 |
-
});
|
384 |
-
</script>
|
385 |
-
</body>
|
386 |
-
</html>
|
|
|
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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|