Spaces:
Running
Running
Add 2 files
Browse files- README.md +7 -5
- index.html +663 -19
README.md
CHANGED
@@ -1,10 +1,12 @@
|
|
1 |
---
|
2 |
-
title:
|
3 |
-
emoji:
|
4 |
-
colorFrom:
|
5 |
-
colorTo:
|
6 |
sdk: static
|
7 |
pinned: false
|
|
|
|
|
8 |
---
|
9 |
|
10 |
-
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
1 |
---
|
2 |
+
title: tanks-game
|
3 |
+
emoji: 🐳
|
4 |
+
colorFrom: gray
|
5 |
+
colorTo: blue
|
6 |
sdk: static
|
7 |
pinned: false
|
8 |
+
tags:
|
9 |
+
- deepsite
|
10 |
---
|
11 |
|
12 |
+
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
index.html
CHANGED
@@ -1,19 +1,663 @@
|
|
1 |
-
<!
|
2 |
-
<html>
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<!DOCTYPE html>
|
2 |
+
<html lang="en">
|
3 |
+
<head>
|
4 |
+
<meta charset="UTF-8">
|
5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
6 |
+
<title>Tank Battle: Ultimate Showdown</title>
|
7 |
+
<script src="https://cdn.tailwindcss.com"></script>
|
8 |
+
<link href="https://fonts.googleapis.com/css2?family=Press+Start+2P&display=swap" rel="stylesheet">
|
9 |
+
<style>
|
10 |
+
body {
|
11 |
+
background: linear-gradient(to bottom, #1a2a6c, #b21f1f, #fdbb2d);
|
12 |
+
font-family: 'Press Start 2P', cursive;
|
13 |
+
overflow: hidden;
|
14 |
+
user-select: none;
|
15 |
+
height: 100vh;
|
16 |
+
margin: 0;
|
17 |
+
display: flex;
|
18 |
+
align-items: center;
|
19 |
+
justify-content: center;
|
20 |
+
}
|
21 |
+
|
22 |
+
#gameContainer {
|
23 |
+
position: relative;
|
24 |
+
width: 100%;
|
25 |
+
max-width: 800px;
|
26 |
+
padding: 20px;
|
27 |
+
margin: 0 auto;
|
28 |
+
}
|
29 |
+
|
30 |
+
#gameCanvas {
|
31 |
+
background: linear-gradient(to bottom, #1e9600, #004e00);
|
32 |
+
box-shadow: 0 0 30px rgba(0, 0, 0, 0.7);
|
33 |
+
border-radius: 5px;
|
34 |
+
border: 4px solid #333;
|
35 |
+
position: relative;
|
36 |
+
width: 100%;
|
37 |
+
height: 400px;
|
38 |
+
overflow: hidden;
|
39 |
+
}
|
40 |
+
|
41 |
+
.tank {
|
42 |
+
position: absolute;
|
43 |
+
transition: transform 0.3s ease;
|
44 |
+
z-index: 10;
|
45 |
+
bottom: 0;
|
46 |
+
}
|
47 |
+
|
48 |
+
.tank-body {
|
49 |
+
position: relative;
|
50 |
+
width: 48px;
|
51 |
+
height: 32px;
|
52 |
+
background-color: #555;
|
53 |
+
border-radius: 5px;
|
54 |
+
border: 2px solid #333;
|
55 |
+
box-shadow: 0 5px 10px rgba(0,0,0,0.3);
|
56 |
+
}
|
57 |
+
|
58 |
+
.tank-barrel {
|
59 |
+
position: absolute;
|
60 |
+
width: 4px;
|
61 |
+
height: 30px;
|
62 |
+
background: linear-gradient(to right, #777, #444);
|
63 |
+
top: -30px;
|
64 |
+
left: 50%;
|
65 |
+
transform-origin: bottom center;
|
66 |
+
transform: translateX(-50%) rotate(45deg);
|
67 |
+
border: 1px solid #222;
|
68 |
+
border-radius: 2px;
|
69 |
+
}
|
70 |
+
|
71 |
+
.tank-turret {
|
72 |
+
position: absolute;
|
73 |
+
width: 20px;
|
74 |
+
height: 20px;
|
75 |
+
background: linear-gradient(to bottom, #666, #444);
|
76 |
+
border-radius: 50%;
|
77 |
+
top: -10px;
|
78 |
+
left: 50%;
|
79 |
+
transform: translateX(-50%);
|
80 |
+
border: 2px solid #333;
|
81 |
+
box-shadow: inset 0 0 5px rgba(0,0,0,0.5);
|
82 |
+
}
|
83 |
+
|
84 |
+
.tank-tracks {
|
85 |
+
position: absolute;
|
86 |
+
bottom: -6px;
|
87 |
+
left: 0;
|
88 |
+
right: 0;
|
89 |
+
height: 6px;
|
90 |
+
background: repeating-linear-gradient(
|
91 |
+
90deg,
|
92 |
+
#444,
|
93 |
+
#444 3px,
|
94 |
+
#333 3px,
|
95 |
+
#333 6px
|
96 |
+
);
|
97 |
+
border-radius: 3px;
|
98 |
+
}
|
99 |
+
|
100 |
+
.explosion {
|
101 |
+
position: absolute;
|
102 |
+
width: 0;
|
103 |
+
height: 0;
|
104 |
+
border-radius: 50%;
|
105 |
+
background: radial-gradient(circle, rgb(255, 255, 0) 0%, rgb(255, 165, 0) 40%, rgb(255, 0, 0) 70%, rgba(139, 0, 0, 0) 100%);
|
106 |
+
opacity: 0;
|
107 |
+
z-index: 20;
|
108 |
+
box-shadow: 0 0 30px rgba(255, 100, 0, 0.7);
|
109 |
+
}
|
110 |
+
|
111 |
+
.projectile {
|
112 |
+
position: absolute;
|
113 |
+
background: radial-gradient(circle at center, #ffeb3b, #ff9800, #f44336);
|
114 |
+
border-radius: 50%;
|
115 |
+
box-shadow: 0 0 10px rgba(255, 165, 0, 0.8);
|
116 |
+
z-index: 15;
|
117 |
+
}
|
118 |
+
|
119 |
+
.projectile-trail {
|
120 |
+
position: absolute;
|
121 |
+
background: rgba(255, 165, 0, 0.5);
|
122 |
+
border-radius: 50%;
|
123 |
+
z-index: 5;
|
124 |
+
}
|
125 |
+
|
126 |
+
.crater {
|
127 |
+
position: absolute;
|
128 |
+
background: radial-gradient(circle, rgba(70, 35, 0, 0.8) 0%, rgba(70, 35, 0, 0) 100%);
|
129 |
+
border-radius: 50%;
|
130 |
+
z-index: 9;
|
131 |
+
}
|
132 |
+
|
133 |
+
.controls {
|
134 |
+
background-color: rgba(0, 0, 0, 0.7);
|
135 |
+
border-radius: 10px;
|
136 |
+
padding: 15px;
|
137 |
+
border: 2px solid #444;
|
138 |
+
box-shadow: inset 0 0 10px rgba(0,0,0,0.5);
|
139 |
+
}
|
140 |
+
|
141 |
+
.slider-label {
|
142 |
+
font-weight: bold;
|
143 |
+
color: #fff;
|
144 |
+
text-shadow: 2px 2px 0 #000;
|
145 |
+
margin-bottom: 5px;
|
146 |
+
font-size: 12px;
|
147 |
+
}
|
148 |
+
|
149 |
+
.health {
|
150 |
+
font-size: 24px;
|
151 |
+
letter-spacing: 3px;
|
152 |
+
}
|
153 |
+
|
154 |
+
input[type="range"] {
|
155 |
+
-webkit-appearance: none;
|
156 |
+
width: 100%;
|
157 |
+
height: 10px;
|
158 |
+
background: #444;
|
159 |
+
border-radius: 5px;
|
160 |
+
outline: none;
|
161 |
+
margin-bottom: 15px;
|
162 |
+
}
|
163 |
+
|
164 |
+
input[type="range"]::-webkit-slider-thumb {
|
165 |
+
-webkit-appearance: none;
|
166 |
+
width: 20px;
|
167 |
+
height: 20px;
|
168 |
+
background: #ff9800;
|
169 |
+
border-radius: 50%;
|
170 |
+
cursor: pointer;
|
171 |
+
border: 2px solid #ff5722;
|
172 |
+
}
|
173 |
+
|
174 |
+
button {
|
175 |
+
background: linear-gradient(to bottom, #ff5722, #e64a19);
|
176 |
+
color: white;
|
177 |
+
border: none;
|
178 |
+
border-radius: 5px;
|
179 |
+
padding: 10px 20px;
|
180 |
+
font-family: 'Press Start 2P', cursive;
|
181 |
+
font-size: 12px;
|
182 |
+
cursor: pointer;
|
183 |
+
text-shadow: 1px 1px 0 #000;
|
184 |
+
box-shadow: 0 5px 0 #c62828, 0 8px 5px rgba(0,0,0,0.3);
|
185 |
+
transition: all 0.1s;
|
186 |
+
outline: none;
|
187 |
+
}
|
188 |
+
|
189 |
+
button:active {
|
190 |
+
transform: translateY(3px);
|
191 |
+
box-shadow: 0 2px 0 #c62828;
|
192 |
+
}
|
193 |
+
|
194 |
+
button:disabled {
|
195 |
+
background: #666;
|
196 |
+
box-shadow: none;
|
197 |
+
transform: none;
|
198 |
+
cursor: not-allowed;
|
199 |
+
}
|
200 |
+
|
201 |
+
.player-turn {
|
202 |
+
box-shadow: 0 0 20px rgba(255, 255, 0, 0.7);
|
203 |
+
transition: all 0.5s;
|
204 |
+
background-color: rgba(255, 255, 0, 0.1);
|
205 |
+
}
|
206 |
+
|
207 |
+
#gameStatus {
|
208 |
+
background-color: rgba(0,0,0,0.7);
|
209 |
+
color: #ff9800;
|
210 |
+
padding: 10px;
|
211 |
+
border-radius: 5px;
|
212 |
+
text-align: center;
|
213 |
+
margin: 10px 0;
|
214 |
+
border: 2px solid #ff5722;
|
215 |
+
text-shadow: 2px 2px 0 #000;
|
216 |
+
}
|
217 |
+
|
218 |
+
#gameOver {
|
219 |
+
position: absolute;
|
220 |
+
top: 50%;
|
221 |
+
left: 50%;
|
222 |
+
transform: translate(-50%, -50%);
|
223 |
+
background: rgba(0,0,0,0.9);
|
224 |
+
padding: 30px;
|
225 |
+
border-radius: 10px;
|
226 |
+
text-align: center;
|
227 |
+
border: 4px solid #ff5722;
|
228 |
+
z-index: 100;
|
229 |
+
width: 80%;
|
230 |
+
max-width: 500px;
|
231 |
+
}
|
232 |
+
|
233 |
+
#winnerMessage {
|
234 |
+
color: #4caf50;
|
235 |
+
font-size: 24px;
|
236 |
+
margin-bottom: 20px;
|
237 |
+
text-shadow: 3px 3px 0 #000;
|
238 |
+
}
|
239 |
+
|
240 |
+
.terrain {
|
241 |
+
position: absolute;
|
242 |
+
z-index: 1;
|
243 |
+
width: 100%;
|
244 |
+
height: 100%;
|
245 |
+
pointer-events: none;
|
246 |
+
bottom: 0;
|
247 |
+
}
|
248 |
+
|
249 |
+
.wind-indicator {
|
250 |
+
position: absolute;
|
251 |
+
top: 10px;
|
252 |
+
left: 50%;
|
253 |
+
transform: translateX(-50%);
|
254 |
+
background: rgba(0,0,0,0.7);
|
255 |
+
padding: 5px 10px;
|
256 |
+
border-radius: 5px;
|
257 |
+
color: white;
|
258 |
+
font-size: 12px;
|
259 |
+
z-index: 50;
|
260 |
+
border: 1px solid #444;
|
261 |
+
}
|
262 |
+
|
263 |
+
@keyframes explosionScale {
|
264 |
+
0% { transform: scale(0); opacity: 1; }
|
265 |
+
100% { transform: scale(4); opacity: 0; }
|
266 |
+
}
|
267 |
+
|
268 |
+
@keyframes explosionFade {
|
269 |
+
0% { opacity: 1; }
|
270 |
+
100% { opacity: 0; }
|
271 |
+
}
|
272 |
+
|
273 |
+
@keyframes fireball {
|
274 |
+
0% { box-shadow: 0 0 10px 5px rgba(255, 165, 0, 0.8); }
|
275 |
+
50% { box-shadow: 0 0 20px 10px rgba(255, 100, 0, 0.9); }
|
276 |
+
100% { box-shadow: 0 0 10px 5px rgba(255, 50, 0, 0.7); }
|
277 |
+
}
|
278 |
+
|
279 |
+
@keyframes tankHit {
|
280 |
+
0% { transform: translateY(0); }
|
281 |
+
25% { transform: translateY(-10px); }
|
282 |
+
50% { transform: translateY(0); }
|
283 |
+
75% { transform: translateY(-5px); }
|
284 |
+
100% { transform: translateY(0); }
|
285 |
+
}
|
286 |
+
|
287 |
+
/* New tank positioning styles */
|
288 |
+
#tankContainer {
|
289 |
+
position: absolute;
|
290 |
+
top: 0;
|
291 |
+
left: 0;
|
292 |
+
width: 100%;
|
293 |
+
height: 100%;
|
294 |
+
pointer-events: none;
|
295 |
+
}
|
296 |
+
|
297 |
+
#player1Tank {
|
298 |
+
bottom: auto;
|
299 |
+
top: 50%;
|
300 |
+
left: 100px;
|
301 |
+
transform: translateY(-50%);
|
302 |
+
}
|
303 |
+
|
304 |
+
#player2Tank {
|
305 |
+
bottom: auto;
|
306 |
+
top: 50%;
|
307 |
+
right: 100px;
|
308 |
+
transform: translateY(-50%) scaleX(-1);
|
309 |
+
}
|
310 |
+
</style>
|
311 |
+
</head>
|
312 |
+
<body>
|
313 |
+
<div id="gameContainer">
|
314 |
+
<div id="gameCanvas">
|
315 |
+
<div id="terrain" class="terrain"></div>
|
316 |
+
<div id="windIndicator" class="wind-indicator">Wind: → 0 m/s</div>
|
317 |
+
|
318 |
+
<div id="tankContainer">
|
319 |
+
<div id="player1Tank" class="tank">
|
320 |
+
<div class="tank-body">
|
321 |
+
<div class="tank-barrel"></div>
|
322 |
+
<div class="tank-turret"></div>
|
323 |
+
<div class="tank-tracks"></div>
|
324 |
+
</div>
|
325 |
+
</div>
|
326 |
+
<div id="player2Tank" class="tank">
|
327 |
+
<div class="tank-body">
|
328 |
+
<div class="tank-barrel"></div>
|
329 |
+
<div class="tank-turret"></div>
|
330 |
+
<div class="tank-tracks"></div>
|
331 |
+
</div>
|
332 |
+
</div>
|
333 |
+
</div>
|
334 |
+
|
335 |
+
<div id="projectiles"></div>
|
336 |
+
<div id="projectileTrails"></div>
|
337 |
+
<div id="explosions"></div>
|
338 |
+
<div id="craters"></div>
|
339 |
+
</div>
|
340 |
+
|
341 |
+
<div id="gameStatus">Player 1's Turn</div>
|
342 |
+
|
343 |
+
<div class="flex flex-col md:flex-row gap-4">
|
344 |
+
<div class="controls flex-1">
|
345 |
+
<h2 class="text-center text-white mb-3 text-sm">PLAYER 1</h2>
|
346 |
+
<div class="mb-3">
|
347 |
+
<div class="flex justify-between">
|
348 |
+
<span class="slider-label">POWER:</span>
|
349 |
+
<span class="slider-label"><span id="player1PowerValue">50</span>%</span>
|
350 |
+
</div>
|
351 |
+
<input type="range" min="5" max="100" value="50" class="w-full" id="player1Power">
|
352 |
+
</div>
|
353 |
+
<div class="mb-3">
|
354 |
+
<div class="flex justify-between">
|
355 |
+
<span class="slider-label">ANGLE:</span>
|
356 |
+
<span class="slider-label"><span id="player1AngleValue">45</span>°</span>
|
357 |
+
</div>
|
358 |
+
<input type="range" min="0" max="90" value="45" class="w-full" id="player1Angle">
|
359 |
+
</div>
|
360 |
+
<div class="flex justify-between items-center mb-3">
|
361 |
+
<span class="slider-label">HEALTH:</span>
|
362 |
+
<span class="health text-red-500" id="player1Health">❤❤❤</span>
|
363 |
+
</div>
|
364 |
+
<button id="player1Shoot" class="w-full">
|
365 |
+
FIRE!
|
366 |
+
</button>
|
367 |
+
</div>
|
368 |
+
|
369 |
+
<div class="controls flex-1">
|
370 |
+
<h2 class="text-center text-white mb-3 text-sm">COMPUTER</h2>
|
371 |
+
<div class="mb-3">
|
372 |
+
<div class="flex justify-between">
|
373 |
+
<span class="slider-label">POWER:</span>
|
374 |
+
<span class="slider-label"><span id="player2PowerValue">50</span>%</span>
|
375 |
+
</div>
|
376 |
+
<input type="range" min="5" max="100" value="50" class="w-full" id="player2Power" disabled>
|
377 |
+
</div>
|
378 |
+
<div class="mb-3">
|
379 |
+
<div class="flex justify-between">
|
380 |
+
<span class="slider-label">ANGLE:</span>
|
381 |
+
<span class="slider-label"><span id="player2AngleValue">45</span>°</span>
|
382 |
+
</div>
|
383 |
+
<input type="range" min="0" max="90" value="45" class="w-full" id="player2Angle" disabled>
|
384 |
+
</div>
|
385 |
+
<div class="flex justify-between items-center mb-3">
|
386 |
+
<span class="slider-label">HEALTH:</span>
|
387 |
+
<span class="health text-red-500" id="player2Health">❤❤❤</span>
|
388 |
+
</div>
|
389 |
+
<button id="player2Shoot" class="w-full" disabled>
|
390 |
+
THINKING...
|
391 |
+
</button>
|
392 |
+
</div>
|
393 |
+
</div>
|
394 |
+
|
395 |
+
<div id="gameOver" class="hidden">
|
396 |
+
<h2 id="winnerMessage">PLAYER 1 WINS!</h2>
|
397 |
+
<button id="restartButton" class="bg-green-500 hover:bg-green-600">
|
398 |
+
PLAY AGAIN
|
399 |
+
</button>
|
400 |
+
</div>
|
401 |
+
</div>
|
402 |
+
|
403 |
+
<script>
|
404 |
+
// Game constants
|
405 |
+
const GAME_WIDTH = 800;
|
406 |
+
const GAME_HEIGHT = 400;
|
407 |
+
const GRAVITY = 0.2;
|
408 |
+
const WIND_MAX = 0.5;
|
409 |
+
|
410 |
+
// Game state
|
411 |
+
let currentPlayer = 1;
|
412 |
+
let player1Health = 3;
|
413 |
+
let player2Health = 3;
|
414 |
+
let gameActive = true;
|
415 |
+
let gamePaused = false;
|
416 |
+
let player1Position = { x: 100, y: GAME_HEIGHT - 50 };
|
417 |
+
let player2Position = { x: GAME_WIDTH - 100, y: GAME_HEIGHT - 50 };
|
418 |
+
let terrain = [];
|
419 |
+
let projectiles = [];
|
420 |
+
let explosions = [];
|
421 |
+
let craters = [];
|
422 |
+
let windSpeed = 0;
|
423 |
+
let trailParticles = [];
|
424 |
+
|
425 |
+
// Initialize game
|
426 |
+
function initGame() {
|
427 |
+
// Reset game state
|
428 |
+
currentPlayer = 1;
|
429 |
+
player1Health = 3;
|
430 |
+
player2Health = 3;
|
431 |
+
gameActive = true;
|
432 |
+
projectiles = [];
|
433 |
+
explosions = [];
|
434 |
+
craters = [];
|
435 |
+
trailParticles = [];
|
436 |
+
|
437 |
+
// Random wind
|
438 |
+
windSpeed = (Math.random() * WIND_MAX * 2) - WIND_MAX;
|
439 |
+
updateWindIndicator();
|
440 |
+
|
441 |
+
// Update UI
|
442 |
+
document.getElementById('player1Health').textContent = '❤'.repeat(player1Health);
|
443 |
+
document.getElementById('player2Health').textContent = '❤'.repeat(player2Health);
|
444 |
+
document.getElementById('gameOver').classList.add('hidden');
|
445 |
+
document.getElementById('gameStatus').textContent = "PLAYER 1'S TURN";
|
446 |
+
|
447 |
+
// Create terrain
|
448 |
+
createTerrain();
|
449 |
+
|
450 |
+
// Position tanks
|
451 |
+
positionTanks();
|
452 |
+
|
453 |
+
// Set up controls
|
454 |
+
setupControls();
|
455 |
+
|
456 |
+
// Update tank angles
|
457 |
+
updateBarrelAngle(1);
|
458 |
+
updateBarrelAngle(2);
|
459 |
+
|
460 |
+
// Highlight current player
|
461 |
+
updatePlayerTurnUI();
|
462 |
+
}
|
463 |
+
|
464 |
+
// Update wind display
|
465 |
+
function updateWindIndicator() {
|
466 |
+
const windIndicator = document.getElementById('windIndicator');
|
467 |
+
const windDirection = windSpeed > 0 ? "→" : "←";
|
468 |
+
const absSpeed = Math.abs(windSpeed).toFixed(1);
|
469 |
+
windIndicator.textContent = `WIND: ${windDirection} ${absSpeed} m/s`;
|
470 |
+
|
471 |
+
// Color based on wind strength
|
472 |
+
const windStrength = Math.abs(windSpeed) / WIND_MAX;
|
473 |
+
if (windStrength > 0.7) {
|
474 |
+
windIndicator.style.color = '#ff5722';
|
475 |
+
} else if (windStrength > 0.3) {
|
476 |
+
windIndicator.style.color = '#ff9800';
|
477 |
+
} else {
|
478 |
+
windIndicator.style.color = 'white';
|
479 |
+
}
|
480 |
+
}
|
481 |
+
|
482 |
+
// Create random terrain
|
483 |
+
function createTerrain() {
|
484 |
+
const terrainDiv = document.getElementById('terrain');
|
485 |
+
terrainDiv.innerHTML = '';
|
486 |
+
|
487 |
+
// Generate simple terrain
|
488 |
+
terrain = [];
|
489 |
+
for (let x = 0; x <= GAME_WIDTH; x += 20) {
|
490 |
+
terrain.push({
|
491 |
+
x,
|
492 |
+
y: GAME_HEIGHT - 50 - Math.sin(x / 100) * 30
|
493 |
+
});
|
494 |
+
}
|
495 |
+
|
496 |
+
// Draw terrain as SVG path
|
497 |
+
const svg = document.createElementNS("http://www.w3.org/2000/svg", "svg");
|
498 |
+
svg.setAttribute("width", "100%");
|
499 |
+
svg.setAttribute("height", "100%");
|
500 |
+
|
501 |
+
const path = document.createElementNS("http://www.w3.org/2000/svg", "path");
|
502 |
+
|
503 |
+
let pathData = `M ${terrain[0].x} ${terrain[0].y}`;
|
504 |
+
for (let i = 1; i < terrain.length; i++) {
|
505 |
+
pathData += ` L ${terrain[i].x} ${terrain[i].y}`;
|
506 |
+
}
|
507 |
+
|
508 |
+
// Close the path to fill
|
509 |
+
pathData += ` L ${GAME_WIDTH} ${GAME_HEIGHT} L 0 ${GAME_HEIGHT} Z`;
|
510 |
+
|
511 |
+
path.setAttribute("d", pathData);
|
512 |
+
path.setAttribute("fill", "#5D4037");
|
513 |
+
path.setAttribute("stroke", "#3E2723");
|
514 |
+
path.setAttribute("stroke-width", "2");
|
515 |
+
svg.appendChild(path);
|
516 |
+
terrainDiv.appendChild(svg);
|
517 |
+
}
|
518 |
+
|
519 |
+
// Position tanks on the terrain
|
520 |
+
function positionTanks() {
|
521 |
+
const tank1 = document.getElementById('player1Tank');
|
522 |
+
const tank2 = document.getElementById('player2Tank');
|
523 |
+
|
524 |
+
tank1.style.left = `${player1Position.x - 24}px`;
|
525 |
+
tank1.style.top = `${player1Position.y - 32}px`;
|
526 |
+
|
527 |
+
tank2.style.right = `${GAME_WIDTH - player2Position.x - 24}px`;
|
528 |
+
tank2.style.top = `${player2Position.y - 32}px`;
|
529 |
+
}
|
530 |
+
|
531 |
+
// Update the barrel angle based on slider
|
532 |
+
function updateBarrelAngle(playerNum) {
|
533 |
+
const angle = parseInt(document.getElementById(`player${playerNum}Angle`).value);
|
534 |
+
document.getElementById(`player${playerNum}AngleValue`).textContent = angle;
|
535 |
+
|
536 |
+
const tank = document.getElementById(`player${playerNum}Tank`);
|
537 |
+
const barrel = tank.querySelector('.tank-barrel');
|
538 |
+
|
539 |
+
// Flip angle for player 2 (computer) who is facing left
|
540 |
+
const angleDeg = playerNum === 1 ? angle : 180 - angle;
|
541 |
+
barrel.style.transform = `translateX(-50%) rotate(${angleDeg}deg)`;
|
542 |
+
}
|
543 |
+
|
544 |
+
// Update power display
|
545 |
+
function updatePowerDisplay(playerNum) {
|
546 |
+
const power = parseInt(document.getElementById(`player${playerNum}Power`).value);
|
547 |
+
document.getElementById(`player${playerNum}PowerValue`).textContent = power;
|
548 |
+
}
|
549 |
+
|
550 |
+
// Set up game controls
|
551 |
+
function setupControls() {
|
552 |
+
// Player 1 controls
|
553 |
+
document.getElementById('player1Angle').addEventListener('input', () => {
|
554 |
+
updateBarrelAngle(1);
|
555 |
+
});
|
556 |
+
|
557 |
+
document.getElementById('player1Power').addEventListener('input', () => {
|
558 |
+
updatePowerDisplay(1);
|
559 |
+
});
|
560 |
+
|
561 |
+
document.getElementById('player1Shoot').addEventListener('click', () => {
|
562 |
+
if (currentPlayer === 1 && gameActive && !gamePaused) {
|
563 |
+
shoot(1);
|
564 |
+
}
|
565 |
+
});
|
566 |
+
|
567 |
+
// Player 2 (computer) controls are disabled
|
568 |
+
document.getElementById('player2Shoot').disabled = true;
|
569 |
+
|
570 |
+
// Restart button
|
571 |
+
document.getElementById('restartButton').addEventListener('click', initGame);
|
572 |
+
}
|
573 |
+
|
574 |
+
// Highlight current player's controls
|
575 |
+
function updatePlayerTurnUI() {
|
576 |
+
// This would highlight the current player's tank and controls
|
577 |
+
// Implementation would go here
|
578 |
+
}
|
579 |
+
|
580 |
+
// Shoot projectile - simplified for visibility demo
|
581 |
+
function shoot(playerNum) {
|
582 |
+
if (!gameActive) return;
|
583 |
+
|
584 |
+
gamePaused = true;
|
585 |
+
|
586 |
+
// Create a simple projectile visualization
|
587 |
+
const projectile = document.createElement('div');
|
588 |
+
projectile.className = 'projectile';
|
589 |
+
projectile.style.width = '8px';
|
590 |
+
projectile.style.height = '8px';
|
591 |
+
|
592 |
+
// Position at tank barrel (simplified)
|
593 |
+
if (playerNum === 1) {
|
594 |
+
projectile.style.left = `${player1Position.x}px`;
|
595 |
+
projectile.style.top = `${player1Position.y - 20}px`;
|
596 |
+
} else {
|
597 |
+
projectile.style.right = `${GAME_WIDTH - player2Position.x}px`;
|
598 |
+
projectile.style.top = `${player2Position.y - 20}px`;
|
599 |
+
}
|
600 |
+
|
601 |
+
document.getElementById('projectiles').appendChild(projectile);
|
602 |
+
|
603 |
+
// Simple animation for demo
|
604 |
+
let pos = 0;
|
605 |
+
const id = setInterval(() => {
|
606 |
+
pos += 5;
|
607 |
+
if (playerNum === 1) {
|
608 |
+
projectile.style.left = `${player1Position.x + pos}px`;
|
609 |
+
projectile.style.top = `${player1Position.y - 20 - pos/2}px`;
|
610 |
+
} else {
|
611 |
+
projectile.style.right = `${GAME_WIDTH - player2Position.x + pos}px`;
|
612 |
+
projectile.style.top = `${player2Position.y - 20 - pos/2}px`;
|
613 |
+
}
|
614 |
+
|
615 |
+
if (pos > 300) {
|
616 |
+
clearInterval(id);
|
617 |
+
createExplosion(
|
618 |
+
playerNum === 1 ?
|
619 |
+
player1Position.x + pos :
|
620 |
+
player2Position.x - pos,
|
621 |
+
(playerNum === 1 ? player1Position.y : player2Position.y) - 20 - pos/2,
|
622 |
+
30
|
623 |
+
);
|
624 |
+
projectile.remove();
|
625 |
+
|
626 |
+
// Switch turns after delay
|
627 |
+
setTimeout(() => {
|
628 |
+
currentPlayer = currentPlayer === 1 ? 2 : 1;
|
629 |
+
document.getElementById('gameStatus').textContent =
|
630 |
+
currentPlayer === 1 ? "PLAYER 1'S TURN" : "COMPUTER'S TURN";
|
631 |
+
gamePaused = false;
|
632 |
+
}, 1000);
|
633 |
+
}
|
634 |
+
}, 20);
|
635 |
+
}
|
636 |
+
|
637 |
+
// Create explosion effect
|
638 |
+
function createExplosion(x, y, size) {
|
639 |
+
const explosion = document.createElement('div');
|
640 |
+
explosion.className = 'explosion';
|
641 |
+
explosion.style.left = `${x - size/2}px`;
|
642 |
+
explosion.style.top = `${y - size/2}px`;
|
643 |
+
explosion.style.width = `${size}px`;
|
644 |
+
explosion.style.height = `${size}px`;
|
645 |
+
|
646 |
+
document.getElementById('explosions').appendChild(explosion);
|
647 |
+
|
648 |
+
// Animate explosion
|
649 |
+
setTimeout(() => {
|
650 |
+
explosion.style.transform = `scale(2)`;
|
651 |
+
explosion.style.opacity = '0';
|
652 |
+
|
653 |
+
setTimeout(() => {
|
654 |
+
explosion.remove();
|
655 |
+
}, 500);
|
656 |
+
}, 50);
|
657 |
+
}
|
658 |
+
|
659 |
+
// Initialize the game
|
660 |
+
document.addEventListener('DOMContentLoaded', initGame);
|
661 |
+
</script>
|
662 |
+
<p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-deepsite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - <a href="https://enzostvs-deepsite.hf.space?remix=zebrakm/tanks-game" style="color: #fff;text-decoration: underline;" target="_blank" >🧬 Remix</a></p></body>
|
663 |
+
</html>
|