Spaces:
Running
Running
Update index.html
Browse files- index.html +30 -17
index.html
CHANGED
@@ -79,23 +79,26 @@
|
|
79 |
<button id="restart" class="button">Restart Game</button>
|
80 |
<canvas id="gameCanvas"></canvas>
|
81 |
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
</
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
</
|
|
|
|
|
97 |
</div>
|
98 |
</div>
|
|
|
99 |
<button id="bossButton" class="button">Fight Boss!</button>
|
100 |
<div id="winMessage" class="button" style="font-size: 72px; background: none;">You Win!</div>
|
101 |
|
@@ -254,13 +257,23 @@
|
|
254 |
document.getElementById('shop').style.display = 'block';
|
255 |
}
|
256 |
|
257 |
-
|
258 |
if (gold >= cost) {
|
259 |
gold -= cost;
|
260 |
playerImg.src = tankImg;
|
261 |
document.getElementById(tankId).style.display = 'none';
|
262 |
document.getElementById('shop').style.display = 'none';
|
263 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
264 |
}
|
265 |
}
|
266 |
|
|
|
79 |
<button id="restart" class="button">Restart Game</button>
|
80 |
<canvas id="gameCanvas"></canvas>
|
81 |
|
82 |
+
<div id="shop" style="display:none; position:fixed; top:50%; left:50%; transform:translate(-50%,-50%); background:rgba(0,0,0,0.9); padding:20px; border-radius:10px; color:white; z-index:1000;">
|
83 |
+
<h2>Tank Shop</h2>
|
84 |
+
<div style="display:flex; gap:20px;">
|
85 |
+
<div id="tank1" style="text-align:center;">
|
86 |
+
<h3>PZ.IV</h3>
|
87 |
+
<img src="player2.png" width="100" height="45">
|
88 |
+
<p>300 Gold</p>
|
89 |
+
<p style="color: #4CAF50;">+50% HP</p>
|
90 |
+
<button onclick="buyTank('player2.png', 300, 'tank1')">Buy</button>
|
91 |
+
</div>
|
92 |
+
<div id="tank2" style="text-align:center;">
|
93 |
+
<h3>TIGER</h3>
|
94 |
+
<img src="player3.png" width="100" height="45">
|
95 |
+
<p>500 Gold</p>
|
96 |
+
<p style="color: #4CAF50;">+100% HP</p>
|
97 |
+
<p style="color: #ff6b6b;">-30% Speed</p>
|
98 |
+
<button onclick="buyTank('player3.png', 500, 'tank2')">Buy</button>
|
99 |
</div>
|
100 |
</div>
|
101 |
+
</div>
|
102 |
<button id="bossButton" class="button">Fight Boss!</button>
|
103 |
<div id="winMessage" class="button" style="font-size: 72px; background: none;">You Win!</div>
|
104 |
|
|
|
257 |
document.getElementById('shop').style.display = 'block';
|
258 |
}
|
259 |
|
260 |
+
function buyTank(tankImg, cost, tankId) {
|
261 |
if (gold >= cost) {
|
262 |
gold -= cost;
|
263 |
playerImg.src = tankImg;
|
264 |
document.getElementById(tankId).style.display = 'none';
|
265 |
document.getElementById('shop').style.display = 'none';
|
266 |
+
|
267 |
+
// ์ ์ฐจ๋ณ ํน์ฑ ์ ์ฉ
|
268 |
+
if (tankId === 'tank1') { // PZ.IV
|
269 |
+
player.maxHealth += 500;
|
270 |
+
player.health = player.maxHealth; // ํ์ฌ ์ฒด๋ ฅ๋ ์ฆ๊ฐ๋ ์ต๋ ์ฒด๋ ฅ์ผ๋ก ์ค์
|
271 |
+
}
|
272 |
+
else if (tankId === 'tank2') { // TIGER
|
273 |
+
player.maxHealth += 1000;
|
274 |
+
player.health = player.maxHealth;
|
275 |
+
player.speed *= 0.7; // ์๋ 30% ๊ฐ์
|
276 |
+
}
|
277 |
}
|
278 |
}
|
279 |
|