Spaces:
Running
Running
Add 2 files
Browse files- README.md +6 -4
- index.html +389 -19
README.md
CHANGED
|
@@ -1,10 +1,12 @@
|
|
| 1 |
---
|
| 2 |
-
title:
|
| 3 |
-
emoji:
|
| 4 |
colorFrom: pink
|
| 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: sharky-poop
|
| 3 |
+
emoji: 🐳
|
| 4 |
colorFrom: pink
|
| 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,389 @@
|
|
| 1 |
-
<!
|
| 2 |
-
<html>
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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>2D Fighting Game</title>
|
| 7 |
+
<script src="https://cdn.tailwindcss.com"></script>
|
| 8 |
+
<style>
|
| 9 |
+
/* Custom CSS for animations and game elements */
|
| 10 |
+
body {
|
| 11 |
+
overflow: hidden;
|
| 12 |
+
background-color: #1a202c;
|
| 13 |
+
}
|
| 14 |
+
|
| 15 |
+
#game-container {
|
| 16 |
+
position: relative;
|
| 17 |
+
width: 800px;
|
| 18 |
+
height: 400px;
|
| 19 |
+
margin: 0 auto;
|
| 20 |
+
background-image: url('https://images.unsplash.com/photo-1542273917363-3b1817f69a2d?ixlib=rb-1.2.1&auto=format&fit=crop&w=800&q=80');
|
| 21 |
+
background-size: cover;
|
| 22 |
+
overflow: hidden;
|
| 23 |
+
}
|
| 24 |
+
|
| 25 |
+
.character {
|
| 26 |
+
position: absolute;
|
| 27 |
+
width: 80px;
|
| 28 |
+
height: 120px;
|
| 29 |
+
bottom: 0;
|
| 30 |
+
transition: transform 0.1s;
|
| 31 |
+
}
|
| 32 |
+
|
| 33 |
+
#player1 {
|
| 34 |
+
left: 100px;
|
| 35 |
+
background-color: #4299e1;
|
| 36 |
+
}
|
| 37 |
+
|
| 38 |
+
#player2 {
|
| 39 |
+
right: 100px;
|
| 40 |
+
background-color: #f56565;
|
| 41 |
+
}
|
| 42 |
+
|
| 43 |
+
.health-bar {
|
| 44 |
+
height: 20px;
|
| 45 |
+
transition: width 0.3s;
|
| 46 |
+
}
|
| 47 |
+
|
| 48 |
+
#player1-health {
|
| 49 |
+
background-color: #4299e1;
|
| 50 |
+
}
|
| 51 |
+
|
| 52 |
+
#player2-health {
|
| 53 |
+
background-color: #f56565;
|
| 54 |
+
}
|
| 55 |
+
|
| 56 |
+
.attack-effect {
|
| 57 |
+
position: absolute;
|
| 58 |
+
width: 40px;
|
| 59 |
+
height: 40px;
|
| 60 |
+
background-color: rgba(255, 255, 0, 0.7);
|
| 61 |
+
border-radius: 50%;
|
| 62 |
+
animation: attack 0.3s forwards;
|
| 63 |
+
opacity: 0;
|
| 64 |
+
}
|
| 65 |
+
|
| 66 |
+
@keyframes attack {
|
| 67 |
+
0% { transform: scale(0.5); opacity: 0.7; }
|
| 68 |
+
100% { transform: scale(1.5); opacity: 0; }
|
| 69 |
+
}
|
| 70 |
+
|
| 71 |
+
.jump {
|
| 72 |
+
animation: jump 0.8s ease-out;
|
| 73 |
+
}
|
| 74 |
+
|
| 75 |
+
@keyframes jump {
|
| 76 |
+
0% { transform: translateY(0); }
|
| 77 |
+
50% { transform: translateY(-150px); }
|
| 78 |
+
100% { transform: translateY(0); }
|
| 79 |
+
}
|
| 80 |
+
|
| 81 |
+
.hit {
|
| 82 |
+
animation: hit 0.3s;
|
| 83 |
+
}
|
| 84 |
+
|
| 85 |
+
@keyframes hit {
|
| 86 |
+
0% { transform: translateX(0); }
|
| 87 |
+
25% { transform: translateX(10px); }
|
| 88 |
+
50% { transform: translateX(-10px); }
|
| 89 |
+
75% { transform: translateX(10px); }
|
| 90 |
+
100% { transform: translateX(0); }
|
| 91 |
+
}
|
| 92 |
+
|
| 93 |
+
#game-over {
|
| 94 |
+
position: absolute;
|
| 95 |
+
top: 0;
|
| 96 |
+
left: 0;
|
| 97 |
+
width: 100%;
|
| 98 |
+
height: 100%;
|
| 99 |
+
background-color: rgba(0, 0, 0, 0.8);
|
| 100 |
+
display: none;
|
| 101 |
+
justify-content: center;
|
| 102 |
+
align-items: center;
|
| 103 |
+
flex-direction: column;
|
| 104 |
+
z-index: 100;
|
| 105 |
+
}
|
| 106 |
+
|
| 107 |
+
.controls {
|
| 108 |
+
position: absolute;
|
| 109 |
+
bottom: 10px;
|
| 110 |
+
width: 100%;
|
| 111 |
+
text-align: center;
|
| 112 |
+
color: white;
|
| 113 |
+
font-size: 14px;
|
| 114 |
+
}
|
| 115 |
+
</style>
|
| 116 |
+
</head>
|
| 117 |
+
<body class="bg-gray-900 text-white">
|
| 118 |
+
<div class="container mx-auto py-8">
|
| 119 |
+
<h1 class="text-4xl font-bold text-center mb-6">2D Fighting Game</h1>
|
| 120 |
+
|
| 121 |
+
<div class="flex justify-between mb-4">
|
| 122 |
+
<div class="w-1/2 pr-4">
|
| 123 |
+
<h2 class="text-xl font-semibold mb-2">Player 1 (Blue)</h2>
|
| 124 |
+
<div class="health-container bg-gray-700 rounded h-6 mb-2">
|
| 125 |
+
<div id="player1-health" class="health-bar rounded" style="width: 100%"></div>
|
| 126 |
+
</div>
|
| 127 |
+
<p class="text-sm">Controls: WASD to move, Space to attack</p>
|
| 128 |
+
</div>
|
| 129 |
+
<div class="w-1/2 pl-4">
|
| 130 |
+
<h2 class="text-xl font-semibold mb-2">Player 2 (Red)</h2>
|
| 131 |
+
<div class="health-container bg-gray-700 rounded h-6 mb-2">
|
| 132 |
+
<div id="player2-health" class="health-bar rounded" style="width: 100%"></div>
|
| 133 |
+
</div>
|
| 134 |
+
<p class="text-sm">Controls: Arrow keys to move, Enter to attack</p>
|
| 135 |
+
</div>
|
| 136 |
+
</div>
|
| 137 |
+
|
| 138 |
+
<div id="game-container" class="border-4 border-gray-600 rounded-lg relative">
|
| 139 |
+
<div id="player1" class="character rounded-t-lg"></div>
|
| 140 |
+
<div id="player2" class="character rounded-t-lg"></div>
|
| 141 |
+
|
| 142 |
+
<div id="game-over">
|
| 143 |
+
<h2 id="winner-text" class="text-4xl font-bold mb-6"></h2>
|
| 144 |
+
<button id="restart-btn" class="px-6 py-3 bg-blue-500 hover:bg-blue-600 rounded-lg font-semibold">
|
| 145 |
+
Play Again
|
| 146 |
+
</button>
|
| 147 |
+
</div>
|
| 148 |
+
|
| 149 |
+
<div class="controls">
|
| 150 |
+
<p>First to reduce opponent's health to zero wins!</p>
|
| 151 |
+
</div>
|
| 152 |
+
</div>
|
| 153 |
+
</div>
|
| 154 |
+
|
| 155 |
+
<script>
|
| 156 |
+
document.addEventListener('DOMContentLoaded', () => {
|
| 157 |
+
// Game elements
|
| 158 |
+
const gameContainer = document.getElementById('game-container');
|
| 159 |
+
const player1 = document.getElementById('player1');
|
| 160 |
+
const player2 = document.getElementById('player2');
|
| 161 |
+
const player1Health = document.getElementById('player1-health');
|
| 162 |
+
const player2Health = document.getElementById('player2-health');
|
| 163 |
+
const gameOverScreen = document.getElementById('game-over');
|
| 164 |
+
const winnerText = document.getElementById('winner-text');
|
| 165 |
+
const restartBtn = document.getElementById('restart-btn');
|
| 166 |
+
|
| 167 |
+
// Game state
|
| 168 |
+
const gameState = {
|
| 169 |
+
player1: {
|
| 170 |
+
x: 100,
|
| 171 |
+
y: 0,
|
| 172 |
+
width: 80,
|
| 173 |
+
height: 120,
|
| 174 |
+
speed: 5,
|
| 175 |
+
health: 100,
|
| 176 |
+
isJumping: false,
|
| 177 |
+
isAttacking: false,
|
| 178 |
+
direction: 'right'
|
| 179 |
+
},
|
| 180 |
+
player2: {
|
| 181 |
+
x: gameContainer.offsetWidth - 180,
|
| 182 |
+
y: 0,
|
| 183 |
+
width: 80,
|
| 184 |
+
height: 120,
|
| 185 |
+
speed: 5,
|
| 186 |
+
health: 100,
|
| 187 |
+
isJumping: false,
|
| 188 |
+
isAttacking: false,
|
| 189 |
+
direction: 'left'
|
| 190 |
+
},
|
| 191 |
+
gameRunning: true
|
| 192 |
+
};
|
| 193 |
+
|
| 194 |
+
// Key states
|
| 195 |
+
const keys = {
|
| 196 |
+
w: false,
|
| 197 |
+
a: false,
|
| 198 |
+
s: false,
|
| 199 |
+
d: false,
|
| 200 |
+
space: false,
|
| 201 |
+
arrowup: false,
|
| 202 |
+
arrowleft: false,
|
| 203 |
+
arrowdown: false,
|
| 204 |
+
arrowright: false,
|
| 205 |
+
enter: false
|
| 206 |
+
};
|
| 207 |
+
|
| 208 |
+
// Event listeners for keyboard
|
| 209 |
+
document.addEventListener('keydown', (e) => {
|
| 210 |
+
if (!gameState.gameRunning) return;
|
| 211 |
+
|
| 212 |
+
switch(e.key.toLowerCase()) {
|
| 213 |
+
case 'w': keys.w = true; break;
|
| 214 |
+
case 'a': keys.a = true; break;
|
| 215 |
+
case 's': keys.s = true; break;
|
| 216 |
+
case 'd': keys.d = true; break;
|
| 217 |
+
case ' ': keys.space = true; break;
|
| 218 |
+
case 'arrowup': keys.arrowup = true; break;
|
| 219 |
+
case 'arrowleft': keys.arrowleft = true; break;
|
| 220 |
+
case 'arrowdown': keys.arrowdown = true; break;
|
| 221 |
+
case 'arrowright': keys.arrowright = true; break;
|
| 222 |
+
case 'enter': keys.enter = true; break;
|
| 223 |
+
}
|
| 224 |
+
});
|
| 225 |
+
|
| 226 |
+
document.addEventListener('keyup', (e) => {
|
| 227 |
+
switch(e.key.toLowerCase()) {
|
| 228 |
+
case 'w': keys.w = false; break;
|
| 229 |
+
case 'a': keys.a = false; break;
|
| 230 |
+
case 's': keys.s = false; break;
|
| 231 |
+
case 'd': keys.d = false; break;
|
| 232 |
+
case ' ': keys.space = false; break;
|
| 233 |
+
case 'arrowup': keys.arrowup = false; break;
|
| 234 |
+
case 'arrowleft': keys.arrowleft = false; break;
|
| 235 |
+
case 'arrowdown': keys.arrowdown = false; break;
|
| 236 |
+
case 'arrowright': keys.arrowright = false; break;
|
| 237 |
+
case 'enter': keys.enter = false; break;
|
| 238 |
+
}
|
| 239 |
+
});
|
| 240 |
+
|
| 241 |
+
// Restart game
|
| 242 |
+
restartBtn.addEventListener('click', () => {
|
| 243 |
+
gameState.player1.health = 100;
|
| 244 |
+
gameState.player2.health = 100;
|
| 245 |
+
gameState.player1.x = 100;
|
| 246 |
+
gameState.player2.x = gameContainer.offsetWidth - 180;
|
| 247 |
+
gameState.player1.isJumping = false;
|
| 248 |
+
gameState.player2.isJumping = false;
|
| 249 |
+
gameState.player1.isAttacking = false;
|
| 250 |
+
gameState.player2.isAttacking = false;
|
| 251 |
+
gameState.gameRunning = true;
|
| 252 |
+
|
| 253 |
+
player1Health.style.width = '100%';
|
| 254 |
+
player2Health.style.width = '100%';
|
| 255 |
+
|
| 256 |
+
gameOverScreen.style.display = 'none';
|
| 257 |
+
});
|
| 258 |
+
|
| 259 |
+
// Game loop
|
| 260 |
+
function gameLoop() {
|
| 261 |
+
if (!gameState.gameRunning) return;
|
| 262 |
+
|
| 263 |
+
// Player 1 movement
|
| 264 |
+
if (keys.a && gameState.player1.x > 0) {
|
| 265 |
+
gameState.player1.x -= gameState.player1.speed;
|
| 266 |
+
gameState.player1.direction = 'left';
|
| 267 |
+
}
|
| 268 |
+
if (keys.d && gameState.player1.x < gameContainer.offsetWidth - gameState.player1.width) {
|
| 269 |
+
gameState.player1.x += gameState.player1.speed;
|
| 270 |
+
gameState.player1.direction = 'right';
|
| 271 |
+
}
|
| 272 |
+
if (keys.w && !gameState.player1.isJumping) {
|
| 273 |
+
gameState.player1.isJumping = true;
|
| 274 |
+
player1.classList.add('jump');
|
| 275 |
+
setTimeout(() => {
|
| 276 |
+
player1.classList.remove('jump');
|
| 277 |
+
gameState.player1.isJumping = false;
|
| 278 |
+
}, 800);
|
| 279 |
+
}
|
| 280 |
+
|
| 281 |
+
// Player 1 attack
|
| 282 |
+
if (keys.space && !gameState.player1.isAttacking) {
|
| 283 |
+
gameState.player1.isAttacking = true;
|
| 284 |
+
const attackX = gameState.player1.direction === 'right' ?
|
| 285 |
+
gameState.player1.x + gameState.player1.width :
|
| 286 |
+
gameState.player1.x - 40;
|
| 287 |
+
|
| 288 |
+
createAttackEffect(attackX, gameState.player1.y + 40, gameState.player1.direction);
|
| 289 |
+
|
| 290 |
+
setTimeout(() => {
|
| 291 |
+
gameState.player1.isAttacking = false;
|
| 292 |
+
}, 300);
|
| 293 |
+
|
| 294 |
+
checkAttackHit('player1');
|
| 295 |
+
}
|
| 296 |
+
|
| 297 |
+
// Player 2 movement
|
| 298 |
+
if (keys.arrowleft && gameState.player2.x > 0) {
|
| 299 |
+
gameState.player2.x -= gameState.player2.speed;
|
| 300 |
+
gameState.player2.direction = 'left';
|
| 301 |
+
}
|
| 302 |
+
if (keys.arrowright && gameState.player2.x < gameContainer.offsetWidth - gameState.player2.width) {
|
| 303 |
+
gameState.player2.x += gameState.player2.speed;
|
| 304 |
+
gameState.player2.direction = 'right';
|
| 305 |
+
}
|
| 306 |
+
if (keys.arrowup && !gameState.player2.isJumping) {
|
| 307 |
+
gameState.player2.isJumping = true;
|
| 308 |
+
player2.classList.add('jump');
|
| 309 |
+
setTimeout(() => {
|
| 310 |
+
player2.classList.remove('jump');
|
| 311 |
+
gameState.player2.isJumping = false;
|
| 312 |
+
}, 800);
|
| 313 |
+
}
|
| 314 |
+
|
| 315 |
+
// Player 2 attack
|
| 316 |
+
if (keys.enter && !gameState.player2.isAttacking) {
|
| 317 |
+
gameState.player2.isAttacking = true;
|
| 318 |
+
const attackX = gameState.player2.direction === 'right' ?
|
| 319 |
+
gameState.player2.x + gameState.player2.width :
|
| 320 |
+
gameState.player2.x - 40;
|
| 321 |
+
|
| 322 |
+
createAttackEffect(attackX, gameState.player2.y + 40, gameState.player2.direction);
|
| 323 |
+
|
| 324 |
+
setTimeout(() => {
|
| 325 |
+
gameState.player2.isAttacking = false;
|
| 326 |
+
}, 300);
|
| 327 |
+
|
| 328 |
+
checkAttackHit('player2');
|
| 329 |
+
}
|
| 330 |
+
|
| 331 |
+
// Update positions
|
| 332 |
+
player1.style.left = gameState.player1.x + 'px';
|
| 333 |
+
player2.style.left = gameState.player2.x + 'px';
|
| 334 |
+
|
| 335 |
+
requestAnimationFrame(gameLoop);
|
| 336 |
+
}
|
| 337 |
+
|
| 338 |
+
// Create attack visual effect
|
| 339 |
+
function createAttackEffect(x, y, direction) {
|
| 340 |
+
const effect = document.createElement('div');
|
| 341 |
+
effect.className = 'attack-effect';
|
| 342 |
+
effect.style.left = x + 'px';
|
| 343 |
+
effect.style.top = y + 'px';
|
| 344 |
+
gameContainer.appendChild(effect);
|
| 345 |
+
|
| 346 |
+
setTimeout(() => {
|
| 347 |
+
effect.remove();
|
| 348 |
+
}, 300);
|
| 349 |
+
}
|
| 350 |
+
|
| 351 |
+
// Check if attack hits opponent
|
| 352 |
+
function checkAttackHit(attacker) {
|
| 353 |
+
const attackerState = gameState[attacker];
|
| 354 |
+
const defender = attacker === 'player1' ? 'player2' : 'player1';
|
| 355 |
+
const defenderState = gameState[defender];
|
| 356 |
+
const defenderElement = document.getElementById(defender);
|
| 357 |
+
|
| 358 |
+
// Simple collision detection
|
| 359 |
+
const attackRange = 50;
|
| 360 |
+
const attackerCenterX = attackerState.x + attackerState.width / 2;
|
| 361 |
+
const defenderCenterX = defenderState.x + defenderState.width / 2;
|
| 362 |
+
const distance = Math.abs(attackerCenterX - defenderCenterX);
|
| 363 |
+
|
| 364 |
+
if (distance < attackRange && !defenderState.isJumping) {
|
| 365 |
+
// Hit successful
|
| 366 |
+
defenderState.health -= 10;
|
| 367 |
+
document.getElementById(`${defender}-health`).style.width = `${defenderState.health}%`;
|
| 368 |
+
|
| 369 |
+
// Visual feedback for hit
|
| 370 |
+
defenderElement.classList.add('hit');
|
| 371 |
+
setTimeout(() => {
|
| 372 |
+
defenderElement.classList.remove('hit');
|
| 373 |
+
}, 300);
|
| 374 |
+
|
| 375 |
+
// Check if game over
|
| 376 |
+
if (defenderState.health <= 0) {
|
| 377 |
+
gameState.gameRunning = false;
|
| 378 |
+
gameOverScreen.style.display = 'flex';
|
| 379 |
+
winnerText.textContent = `${attacker === 'player1' ? 'Player 1 (Blue)' : 'Player 2 (Red)'} Wins!`;
|
| 380 |
+
}
|
| 381 |
+
}
|
| 382 |
+
}
|
| 383 |
+
|
| 384 |
+
// Start the game
|
| 385 |
+
gameLoop();
|
| 386 |
+
});
|
| 387 |
+
</script>
|
| 388 |
+
<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=pijou/sharky-poop" style="color: #fff;text-decoration: underline;" target="_blank" >🧬 Remix</a></p></body>
|
| 389 |
+
</html>
|