Spaces:
Running
Running
🐳 13/02 - 02:47 - Activate enemy mode, where anger will kill the red devourer.
Browse files
game.js
CHANGED
|
@@ -18,9 +18,14 @@ const enemy = {
|
|
| 18 |
radius: 18,
|
| 19 |
color: '#DC143C',
|
| 20 |
speed: 2.5,
|
| 21 |
-
stolenScore: 0
|
|
|
|
|
|
|
| 22 |
};
|
| 23 |
|
|
|
|
|
|
|
|
|
|
| 24 |
let playerMoveCount = 0;
|
| 25 |
let lastPlayerX = null;
|
| 26 |
let lastPlayerY = null;
|
|
@@ -72,6 +77,13 @@ function movePlayer(e) {
|
|
| 72 |
return;
|
| 73 |
}
|
| 74 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 75 |
// Store position before move
|
| 76 |
lastPlayerX = player.x;
|
| 77 |
lastPlayerY = player.y;
|
|
@@ -102,6 +114,12 @@ function resetGame() {
|
|
| 102 |
enemy.x = 50;
|
| 103 |
enemy.y = 50;
|
| 104 |
enemy.stolenScore = 0;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 105 |
|
| 106 |
// Reset game state
|
| 107 |
score = 0;
|
|
@@ -132,7 +150,18 @@ function resetGame() {
|
|
| 132 |
}
|
| 133 |
|
| 134 |
function moveEnemy() {
|
| 135 |
-
if (!gameRunning)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 136 |
|
| 137 |
// Enemy only moves once for every 2 player moves
|
| 138 |
if (playerMoveCount % 2 !== 0) return;
|
|
@@ -191,23 +220,39 @@ function checkCollision() {
|
|
| 191 |
}
|
| 192 |
|
| 193 |
// Check enemy collision with player
|
| 194 |
-
|
| 195 |
-
|
| 196 |
-
|
| 197 |
-
|
| 198 |
-
|
| 199 |
-
|
| 200 |
-
|
| 201 |
-
|
| 202 |
-
|
| 203 |
-
|
| 204 |
-
|
| 205 |
-
|
| 206 |
-
|
| 207 |
-
|
| 208 |
-
|
| 209 |
-
|
| 210 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 211 |
}
|
| 212 |
}
|
| 213 |
|
|
@@ -228,29 +273,86 @@ function draw() {
|
|
| 228 |
// Clear canvas
|
| 229 |
ctx.clearRect(0, 0, canvas.width, canvas.height);
|
| 230 |
|
| 231 |
-
// Draw player
|
| 232 |
ctx.beginPath();
|
| 233 |
ctx.arc(player.x, player.y, player.radius, 0, Math.PI * 2);
|
| 234 |
-
|
| 235 |
-
|
| 236 |
-
|
| 237 |
-
|
| 238 |
-
|
| 239 |
-
|
| 240 |
-
|
|
|
|
|
|
|
|
|
|
| 241 |
ctx.fill();
|
|
|
|
| 242 |
|
| 243 |
-
// Draw
|
| 244 |
-
|
| 245 |
-
|
| 246 |
-
|
| 247 |
-
|
| 248 |
-
|
| 249 |
-
|
| 250 |
-
|
| 251 |
-
|
| 252 |
-
|
| 253 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 254 |
|
| 255 |
// Draw toppings
|
| 256 |
drawToppings(toppings.beef);
|
|
|
|
| 18 |
radius: 18,
|
| 19 |
color: '#DC143C',
|
| 20 |
speed: 2.5,
|
| 21 |
+
stolenScore: 0,
|
| 22 |
+
alive: true,
|
| 23 |
+
respawnTimer: 0
|
| 24 |
};
|
| 25 |
|
| 26 |
+
let angerMode = false;
|
| 27 |
+
let angerCooldown = 0;
|
| 28 |
+
|
| 29 |
let playerMoveCount = 0;
|
| 30 |
let lastPlayerX = null;
|
| 31 |
let lastPlayerY = null;
|
|
|
|
| 77 |
return;
|
| 78 |
}
|
| 79 |
|
| 80 |
+
// Activate anger mode with Shift
|
| 81 |
+
if (e.key === 'Shift' && angerCooldown <= 0 && !angerMode) {
|
| 82 |
+
angerMode = true;
|
| 83 |
+
angerCooldown = 300; // 5 seconds at 60fps
|
| 84 |
+
setTimeout(() => { angerMode = false; }, 2000); // Anger lasts 2 seconds
|
| 85 |
+
}
|
| 86 |
+
|
| 87 |
// Store position before move
|
| 88 |
lastPlayerX = player.x;
|
| 89 |
lastPlayerY = player.y;
|
|
|
|
| 114 |
enemy.x = 50;
|
| 115 |
enemy.y = 50;
|
| 116 |
enemy.stolenScore = 0;
|
| 117 |
+
enemy.alive = true;
|
| 118 |
+
enemy.respawnTimer = 0;
|
| 119 |
+
|
| 120 |
+
// Reset anger mode
|
| 121 |
+
angerMode = false;
|
| 122 |
+
angerCooldown = 0;
|
| 123 |
|
| 124 |
// Reset game state
|
| 125 |
score = 0;
|
|
|
|
| 150 |
}
|
| 151 |
|
| 152 |
function moveEnemy() {
|
| 153 |
+
if (!gameRunning || !enemy.alive) {
|
| 154 |
+
// Handle respawn
|
| 155 |
+
if (!enemy.alive) {
|
| 156 |
+
enemy.respawnTimer--;
|
| 157 |
+
if (enemy.respawnTimer <= 0) {
|
| 158 |
+
enemy.alive = true;
|
| 159 |
+
enemy.x = 50;
|
| 160 |
+
enemy.y = 50;
|
| 161 |
+
}
|
| 162 |
+
}
|
| 163 |
+
return;
|
| 164 |
+
}
|
| 165 |
|
| 166 |
// Enemy only moves once for every 2 player moves
|
| 167 |
if (playerMoveCount % 2 !== 0) return;
|
|
|
|
| 220 |
}
|
| 221 |
|
| 222 |
// Check enemy collision with player
|
| 223 |
+
if (enemy.alive) {
|
| 224 |
+
const enemyDist = Math.hypot(player.x - enemy.x, player.y - enemy.y);
|
| 225 |
+
if (enemyDist < player.radius + enemy.radius) {
|
| 226 |
+
if (angerMode) {
|
| 227 |
+
// Player kills enemy with anger!
|
| 228 |
+
enemy.alive = false;
|
| 229 |
+
enemy.respawnTimer = 180; // Respawn after 3 seconds
|
| 230 |
+
score += 25; // Bonus for killing enemy
|
| 231 |
+
scoreElement.textContent = score;
|
| 232 |
+
|
| 233 |
+
// Visual feedback
|
| 234 |
+
ctx.fillStyle = 'white';
|
| 235 |
+
ctx.font = 'bold 30px Arial';
|
| 236 |
+
ctx.textAlign = 'center';
|
| 237 |
+
ctx.fillText('💥 RAGE KILL! 💥', canvas.width/2, canvas.height/2);
|
| 238 |
+
} else {
|
| 239 |
+
// Enemy steals points from player
|
| 240 |
+
if (score > 0) {
|
| 241 |
+
const stealAmount = Math.min(10, score); // Steal up to 10 points at a time
|
| 242 |
+
score -= stealAmount;
|
| 243 |
+
enemy.stolenScore += stealAmount;
|
| 244 |
+
scoreElement.textContent = score;
|
| 245 |
+
|
| 246 |
+
// Push player away from enemy
|
| 247 |
+
const pushAngle = Math.atan2(player.y - enemy.y, player.x - enemy.x);
|
| 248 |
+
player.x += Math.cos(pushAngle) * 30;
|
| 249 |
+
player.y += Math.sin(pushAngle) * 30;
|
| 250 |
+
|
| 251 |
+
// Boundary check after push
|
| 252 |
+
player.x = Math.max(player.radius, Math.min(canvas.width - player.radius, player.x));
|
| 253 |
+
player.y = Math.max(player.radius, Math.min(canvas.height - player.radius, player.y));
|
| 254 |
+
}
|
| 255 |
+
}
|
| 256 |
}
|
| 257 |
}
|
| 258 |
|
|
|
|
| 273 |
// Clear canvas
|
| 274 |
ctx.clearRect(0, 0, canvas.width, canvas.height);
|
| 275 |
|
| 276 |
+
// Draw player (glows red when angry)
|
| 277 |
ctx.beginPath();
|
| 278 |
ctx.arc(player.x, player.y, player.radius, 0, Math.PI * 2);
|
| 279 |
+
if (angerMode) {
|
| 280 |
+
// Pulsing red glow
|
| 281 |
+
const pulse = Math.sin(Date.now() / 100) * 5 + 10;
|
| 282 |
+
ctx.shadowBlur = 20;
|
| 283 |
+
ctx.shadowColor = '#FF0000';
|
| 284 |
+
ctx.fillStyle = '#FF0000';
|
| 285 |
+
} else {
|
| 286 |
+
ctx.shadowBlur = 0;
|
| 287 |
+
ctx.fillStyle = player.color;
|
| 288 |
+
}
|
| 289 |
ctx.fill();
|
| 290 |
+
ctx.shadowBlur = 0; // Reset shadow
|
| 291 |
|
| 292 |
+
// Draw anger meter/cooldown
|
| 293 |
+
if (angerCooldown > 0) {
|
| 294 |
+
angerCooldown--;
|
| 295 |
+
ctx.fillStyle = 'rgba(255, 0, 0, 0.3)';
|
| 296 |
+
ctx.fillRect(10, 70, 200, 20);
|
| 297 |
+
ctx.fillStyle = angerCooldown > 0 ? '#FF0000' : '#00FF00';
|
| 298 |
+
const cooldownWidth = (1 - angerCooldown / 300) * 200;
|
| 299 |
+
ctx.fillRect(10, 70, cooldownWidth, 20);
|
| 300 |
+
ctx.strokeStyle = '#8B4513';
|
| 301 |
+
ctx.lineWidth = 2;
|
| 302 |
+
ctx.strokeRect(10, 70, 200, 20);
|
| 303 |
+
ctx.fillStyle = '#8B4513';
|
| 304 |
+
ctx.font = 'bold 14px Arial';
|
| 305 |
+
ctx.textAlign = 'left';
|
| 306 |
+
ctx.fillText(angerMode ? '🔥 RAGE ACTIVE! 🔥' : (angerCooldown <= 0 ? 'SHIFT: ACTIVATE RAGE' : 'RAGE COOLDOWN'), 15, 85);
|
| 307 |
+
} else {
|
| 308 |
+
ctx.fillStyle = '#00AA00';
|
| 309 |
+
ctx.font = 'bold 14px Arial';
|
| 310 |
+
ctx.textAlign = 'left';
|
| 311 |
+
ctx.fillText('✓ SHIFT: ACTIVATE RAGE MODE', 15, 85);
|
| 312 |
+
}
|
| 313 |
+
|
| 314 |
+
// Draw enemy if alive
|
| 315 |
+
if (enemy.alive) {
|
| 316 |
+
ctx.beginPath();
|
| 317 |
+
ctx.arc(enemy.x, enemy.y, enemy.radius, 0, Math.PI * 2);
|
| 318 |
+
ctx.fillStyle = angerMode ? '#FF0000' : enemy.color;
|
| 319 |
+
ctx.fill();
|
| 320 |
+
|
| 321 |
+
// Draw enemy eyes (angry when player is in anger mode)
|
| 322 |
+
ctx.fillStyle = angerMode ? '#FF0000' : 'white';
|
| 323 |
+
ctx.beginPath();
|
| 324 |
+
ctx.arc(enemy.x - 6, enemy.y - 4, 4, 0, Math.PI * 2);
|
| 325 |
+
ctx.arc(enemy.x + 6, enemy.y - 4, 4, 0, Math.PI * 2);
|
| 326 |
+
ctx.fill();
|
| 327 |
+
ctx.fillStyle = angerMode ? '#000' : 'black';
|
| 328 |
+
ctx.beginPath();
|
| 329 |
+
ctx.arc(enemy.x - 6, enemy.y - 4, 2, 0, Math.PI * 2);
|
| 330 |
+
ctx.arc(enemy.x + 6, enemy.y - 4, 2, 0, Math.PI * 2);
|
| 331 |
+
ctx.fill();
|
| 332 |
+
|
| 333 |
+
// Draw scared eyebrows when player is angry
|
| 334 |
+
if (angerMode) {
|
| 335 |
+
ctx.strokeStyle = '#000';
|
| 336 |
+
ctx.lineWidth = 2;
|
| 337 |
+
ctx.beginPath();
|
| 338 |
+
ctx.moveTo(enemy.x - 10, enemy.y - 8);
|
| 339 |
+
ctx.lineTo(enemy.x - 2, enemy.y - 6);
|
| 340 |
+
ctx.moveTo(enemy.x + 10, enemy.y - 8);
|
| 341 |
+
ctx.lineTo(enemy.x + 2, enemy.y - 6);
|
| 342 |
+
ctx.stroke();
|
| 343 |
+
}
|
| 344 |
+
} else {
|
| 345 |
+
// Draw skull when enemy is dead
|
| 346 |
+
ctx.fillStyle = 'rgba(100, 100, 100, 0.5)';
|
| 347 |
+
ctx.font = '30px Arial';
|
| 348 |
+
ctx.textAlign = 'center';
|
| 349 |
+
ctx.fillText('💀', enemy.x, enemy.y + 10);
|
| 350 |
+
|
| 351 |
+
// Respawn countdown
|
| 352 |
+
ctx.fillStyle = '#DC143C';
|
| 353 |
+
ctx.font = 'bold 16px Arial';
|
| 354 |
+
ctx.fillText('RESPAWN: ' + Math.ceil(enemy.respawnTimer/60), enemy.x, enemy.y - 25);
|
| 355 |
+
}
|
| 356 |
|
| 357 |
// Draw toppings
|
| 358 |
drawToppings(toppings.beef);
|
style.css
CHANGED
|
@@ -1,4 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2 |
body {
|
| 3 |
margin: 0;
|
| 4 |
padding: 0;
|
|
|
|
| 1 |
+
body {
|
| 2 |
+
margin: 0;
|
| 3 |
+
padding: 0;
|
| 4 |
+
font-family: 'Arial', sans-serif;
|
| 5 |
+
background-color: #FFF5E6;
|
| 6 |
+
display: flex;
|
| 7 |
+
justify-content: center;
|
| 8 |
+
align-items: center;
|
| 9 |
+
height: 100vh;
|
| 10 |
+
}
|
| 11 |
|
| 12 |
+
.game-container {
|
| 13 |
+
position: relative;
|
| 14 |
+
text-align: center;
|
| 15 |
+
}
|
| 16 |
+
|
| 17 |
+
#gameCanvas {
|
| 18 |
+
background-color: #FFE4B5;
|
| 19 |
+
border: 5px solid #8B4513;
|
| 20 |
+
border-radius: 10px;
|
| 21 |
+
box-shadow: 0 0 20px rgba(0, 0, 0, 0.2);
|
| 22 |
+
}
|
| 23 |
+
|
| 24 |
+
.game-info {
|
| 25 |
+
position: absolute;
|
| 26 |
+
top: 10px;
|
| 27 |
+
left: 10px;
|
| 28 |
+
background-color: rgba(255, 255, 255, 0.7);
|
| 29 |
+
padding: 10px;
|
| 30 |
+
border-radius: 5px;
|
| 31 |
+
font-weight: bold;
|
| 32 |
+
font-size: 18px;
|
| 33 |
+
}
|
| 34 |
+
|
| 35 |
+
.game-info::after {
|
| 36 |
+
content: "SHIFT = Rage Kill! Avoid the Red Devourer!";
|
| 37 |
+
display: block;
|
| 38 |
+
color: #DC143C;
|
| 39 |
+
font-size: 14px;
|
| 40 |
+
margin-top: 5px;
|
| 41 |
+
}
|
| 42 |
body {
|
| 43 |
margin: 0;
|
| 44 |
padding: 0;
|