@@ -1,5 +1,5 @@ |
| 1 | // Matter.js module aliases | 1 | // Matter.js module aliases |
| 2 | -const Body = Matter.Body; | 2 | +const Body = Matter.Body; |
| 3 | const World = Matter.World; | 3 | const World = Matter.World; |
| 4 | const Engine = Matter.Engine; | 4 | const Engine = Matter.Engine; |
| 5 | const Bodies = Matter.Bodies; | 5 | const Bodies = Matter.Bodies; |
@@ -25,6 +25,10 @@ let gameStarted = false; |
| 25 | let keys = {}; | 25 | let keys = {}; |
| 26 | let inputBuffer = { left: 0, right: 0 }; | 26 | let inputBuffer = { left: 0, right: 0 }; |
| 27 | | 27 | |
| | 28 | +// Particle systems |
| | 29 | +let particles = []; |
| | 30 | +let impactParticles = []; |
| | 31 | + |
| 28 | // Canvas settings | 32 | // Canvas settings |
| 29 | const CANVAS_WIDTH = 800; | 33 | const CANVAS_WIDTH = 800; |
| 30 | const CANVAS_HEIGHT = 400; | 34 | const CANVAS_HEIGHT = 400; |
@@ -36,21 +40,27 @@ const PADDLE_WIDTH = 20; |
| 36 | const PADDLE_HEIGHT = 80; | 40 | const PADDLE_HEIGHT = 80; |
| 37 | | 41 | |
| 38 | // Enhanced movement constants | 42 | // Enhanced movement constants |
| 39 | -const SUPPORT_SPEED = 4.5; | 43 | +const SUPPORT_SPEED = 6.5; |
| 40 | -const SUPPORT_ACCEL = 0.8; | 44 | +const SUPPORT_ACCEL = 1.2; |
| 41 | -const INPUT_SMOOTHING = 0.15; | 45 | +const INPUT_SMOOTHING = 0.25 |
| 42 | -const SUPPORT_MAX_SPEED = 6; | 46 | +const SUPPORT_MAX_SPEED = 8; |
| 43 | | 47 | |
| 44 | // Spring physics constants | 48 | // Spring physics constants |
| 45 | -const PADDLE_MASS = 0.8; | 49 | +const PADDLE_MASS = 0.6; |
| 46 | const SPRING_LENGTH = 40; | 50 | const SPRING_LENGTH = 40; |
| 47 | -const SPRING_DAMPING = 0.8; | 51 | +const SPRING_DAMPING = 0.4; |
| 48 | -const SPRING_STIFFNESS = 0.02; | 52 | +const SPRING_STIFFNESS = 0.035; |
| 49 | | 53 | |
| 50 | // Visual enhancement constants | 54 | // Visual enhancement constants |
| 51 | const TRAIL_SEGMENTS = 8; | 55 | const TRAIL_SEGMENTS = 8; |
| 52 | const PADDLE_GLOW_DISTANCE = 25; | 56 | const PADDLE_GLOW_DISTANCE = 25; |
| 53 | -const SPRING_GLOW_INTENSITY = 80; | 57 | +const SPRING_GLOW_INTENSITY = 120; |
| | 58 | + |
| | 59 | +// Particle system constants |
| | 60 | +const MAX_PARTICLES = 100; |
| | 61 | +const PARTICLE_LIFE = 60; |
| | 62 | +const IMPACT_PARTICLES = 8; |
| | 63 | +const SPRING_PARTICLE_RATE = 0.3; |
| 54 | | 64 | |
| 55 | function setup() { | 65 | function setup() { |
| 56 | // Create p5.js canvas | 66 | // Create p5.js canvas |
@@ -87,9 +97,9 @@ function setup() { |
| 87 | } | 97 | } |
| 88 | | 98 | |
| 89 | function createSpringPaddleSystem(side) { | 99 | function createSpringPaddleSystem(side) { |
| 90 | - let supportX = side === 'left' ? 60 : width - 60; | 100 | + let startY = height / 2; |
| 91 | - let paddleX = side === 'left' ? 60 + SPRING_LENGTH : width - 60 - SPRING_LENGTH; | 101 | + let supportX = side === 'left' ? 60 : width - 60; |
| 92 | - let startY = height / 2; | 102 | + let paddleX = side === 'left' ? 60 + SPRING_LENGTH : width - 60 - SPRING_LENGTH; |
| 93 | | 103 | |
| 94 | if (side === 'left') { | 104 | if (side === 'left') { |
| 95 | // Left support (invisible anchor point controlled by player) | 105 | // Left support (invisible anchor point controlled by player) |
@@ -101,9 +111,9 @@ function createSpringPaddleSystem(side) { |
| 101 | // Left paddle (the actual hitting surface) | 111 | // Left paddle (the actual hitting surface) |
| 102 | leftPaddle = Bodies.rectangle(paddleX, startY, PADDLE_WIDTH, PADDLE_HEIGHT, { | 112 | leftPaddle = Bodies.rectangle(paddleX, startY, PADDLE_WIDTH, PADDLE_HEIGHT, { |
| 103 | mass: PADDLE_MASS, | 113 | mass: PADDLE_MASS, |
| 104 | - restitution: 1.2, | 114 | + restitution: 1.3, |
| 105 | friction: 0, | 115 | friction: 0, |
| 106 | - frictionAir: 0.01 | 116 | + frictionAir: 0.005 // Less air resistance |
| 107 | }); | 117 | }); |
| 108 | | 118 | |
| 109 | // Spring constraint connecting support to paddle | 119 | // Spring constraint connecting support to paddle |
@@ -124,9 +134,9 @@ function createSpringPaddleSystem(side) { |
| 124 | // Right paddle (the actual hitting surface) | 134 | // Right paddle (the actual hitting surface) |
| 125 | rightPaddle = Bodies.rectangle(paddleX, startY, PADDLE_WIDTH, PADDLE_HEIGHT, { | 135 | rightPaddle = Bodies.rectangle(paddleX, startY, PADDLE_WIDTH, PADDLE_HEIGHT, { |
| 126 | mass: PADDLE_MASS, | 136 | mass: PADDLE_MASS, |
| 127 | - restitution: 1.2, | 137 | + restitution: 1.3, |
| 128 | friction: 0, | 138 | friction: 0, |
| 129 | - frictionAir: 0.01 | 139 | + frictionAir: 0.005 |
| 130 | }); | 140 | }); |
| 131 | | 141 | |
| 132 | // Spring constraint connecting support to paddle | 142 | // Spring constraint connecting support to paddle |
@@ -147,12 +157,19 @@ function draw() { |
| 147 | // Handle enhanced player input | 157 | // Handle enhanced player input |
| 148 | handleEnhancedInput(); | 158 | handleEnhancedInput(); |
| 149 | | 159 | |
| | 160 | + // Update particle systems |
| | 161 | + updateParticles(); |
| | 162 | + checkCollisions(); |
| | 163 | + |
| 150 | // Check for scoring | 164 | // Check for scoring |
| 151 | checkBallPosition(); | 165 | checkBallPosition(); |
| 152 | | 166 | |
| 153 | // Clear canvas | 167 | // Clear canvas |
| 154 | background(10, 10, 10); | 168 | background(10, 10, 10); |
| 155 | | 169 | |
| | 170 | + // Draw particles behind everything |
| | 171 | + drawParticles(); |
| | 172 | + |
| 156 | // Draw game objects with enhanced visuals | 173 | // Draw game objects with enhanced visuals |
| 157 | drawSpringPaddleSystemsEnhanced(); | 174 | drawSpringPaddleSystemsEnhanced(); |
| 158 | drawBallEnhanced(); | 175 | drawBallEnhanced(); |
@@ -170,16 +187,16 @@ function draw() { |
| 170 | | 187 | |
| 171 | function handleEnhancedInput() { | 188 | function handleEnhancedInput() { |
| 172 | // Smooth input accumulation with acceleration | 189 | // Smooth input accumulation with acceleration |
| 173 | - let leftInput = 0; | 190 | + let leftInput = 0; |
| 174 | - let rightInput = 0; | 191 | + let rightInput = 0; |
| 175 | | 192 | |
| 176 | // Left paddle input (W/S keys) | 193 | // Left paddle input (W/S keys) |
| 177 | if (keys['w'] || keys['W']) leftInput -= 1; | 194 | if (keys['w'] || keys['W']) leftInput -= 1; |
| 178 | if (keys['s'] || keys['S']) leftInput += 1; | 195 | if (keys['s'] || keys['S']) leftInput += 1; |
| 179 | | 196 | |
| 180 | // Right paddle input (Arrow keys) | 197 | // Right paddle input (Arrow keys) |
| 181 | - if (keys['ArrowUp']) rightInput -= 1; | 198 | + if (keys['ArrowUp']) rightInput -= 1; |
| 182 | - if (keys['ArrowDown']) rightInput += 1; | 199 | + if (keys['ArrowDown']) rightInput += 1; |
| 183 | | 200 | |
| 184 | // Apply acceleration and smoothing | 201 | // Apply acceleration and smoothing |
| 185 | inputBuffer.left = lerp(inputBuffer.left, leftInput, INPUT_SMOOTHING); | 202 | inputBuffer.left = lerp(inputBuffer.left, leftInput, INPUT_SMOOTHING); |
@@ -210,8 +227,125 @@ function moveSupportEnhanced(support, deltaY) { |
| 210 | Body.setPosition(support, { x: support.position.x, y: newY }); | 227 | Body.setPosition(support, { x: support.position.x, y: newY }); |
| 211 | } | 228 | } |
| 212 | | 229 | |
| | 230 | +function checkCollisions() { |
| | 231 | + let ballPos = ball.position; |
| | 232 | + let ballVel = ball.velocity; |
| | 233 | + |
| | 234 | + // Check paddle collisions for particle effects |
| | 235 | + let leftDist = dist(ballPos.x, ballPos.y, leftPaddle.position.x, leftPaddle.position.y); |
| | 236 | + let rightDist = dist(ballPos.x, ballPos.y, rightPaddle.position.x, rightPaddle.position.y); |
| | 237 | + |
| | 238 | + // Collision threshold |
| | 239 | + let collisionDist = BALL_RADIUS + PADDLE_WIDTH/2 + 5; |
| | 240 | + |
| | 241 | + // Left paddle collision |
| | 242 | + if (leftDist < collisionDist && ballVel.x < 0) { |
| | 243 | + createImpactParticles(ballPos.x, ballPos.y, ballVel.x, ballVel.y); |
| | 244 | + } |
| | 245 | + |
| | 246 | + // Right paddle collision |
| | 247 | + if (rightDist < collisionDist && ballVel.x > 0) { |
| | 248 | + createImpactParticles(ballPos.x, ballPos.y, ballVel.x, ballVel.y); |
| | 249 | + } |
| | 250 | +} |
| | 251 | + |
| | 252 | +function createImpactParticles(x, y, velX, velY) { |
| | 253 | + for (let i = 0; i < IMPACT_PARTICLES; i++) { |
| | 254 | + let angle = random(TWO_PI); |
| | 255 | + let speed = random(2, 8); |
| | 256 | + let size = random(2, 6); |
| | 257 | + |
| | 258 | + particles.push({ |
| | 259 | + x: x + random(-5, 5), |
| | 260 | + y: y + random(-5, 5), |
| | 261 | + vx: cos(angle) * speed - velX * 0.2, |
| | 262 | + vy: sin(angle) * speed - velY * 0.2, |
| | 263 | + size: size, |
| | 264 | + life: PARTICLE_LIFE, |
| | 265 | + maxLife: PARTICLE_LIFE, |
| | 266 | + color: { r: 255, g: random(100, 255), b: random(100, 150) }, |
| | 267 | + type: 'impact' |
| | 268 | + }); |
| | 269 | + } |
| | 270 | +} |
| | 271 | + |
| | 272 | +function createSpringParticles(springPos, compression) { |
| | 273 | + if (random() < SPRING_PARTICLE_RATE * compression) { |
| | 274 | + let angle = random(TWO_PI); |
| | 275 | + let speed = random(1, 3) * compression; |
| | 276 | + |
| | 277 | + particles.push({ |
| | 278 | + x: springPos.x + random(-10, 10), |
| | 279 | + y: springPos.y + random(-10, 10), |
| | 280 | + vx: cos(angle) * speed, |
| | 281 | + vy: sin(angle) * speed, |
| | 282 | + size: random(1, 3), |
| | 283 | + life: PARTICLE_LIFE * 0.5, |
| | 284 | + maxLife: PARTICLE_LIFE * 0.5, |
| | 285 | + color: { r: 0, g: 255, b: 136 }, |
| | 286 | + type: 'spring' |
| | 287 | + }); |
| | 288 | + } |
| | 289 | +} |
| | 290 | + |
| | 291 | +function updateParticles() { |
| | 292 | + // Update and remove dead particles |
| | 293 | + for (let i = particles.length - 1; i >= 0; i--) { |
| | 294 | + let p = particles[i]; |
| | 295 | + |
| | 296 | + // Update position |
| | 297 | + p.x += p.vx; |
| | 298 | + p.y += p.vy; |
| | 299 | + |
| | 300 | + // Apply drag |
| | 301 | + p.vx *= 0.98; |
| | 302 | + p.vy *= 0.98; |
| | 303 | + |
| | 304 | + // Update life |
| | 305 | + p.life--; |
| | 306 | + |
| | 307 | + // Remove dead particles |
| | 308 | + if (p.life <= 0) { |
| | 309 | + particles.splice(i, 1); |
| | 310 | + } |
| | 311 | + } |
| | 312 | + |
| | 313 | + // Limit particle count |
| | 314 | + if (particles.length > MAX_PARTICLES) { |
| | 315 | + particles.splice(0, particles.length - MAX_PARTICLES); |
| | 316 | + } |
| | 317 | +} |
| | 318 | + |
| | 319 | +function drawParticles() { |
| | 320 | + for (let p of particles) { |
| | 321 | + let alpha = map(p.life, 0, p.maxLife, 0, 255); |
| | 322 | + |
| | 323 | + push(); |
| | 324 | + translate(p.x, p.y); |
| | 325 | + |
| | 326 | + if (p.type === 'impact') { |
| | 327 | + // Impact particles: bright sparks |
| | 328 | + fill(p.color.r, p.color.g, p.color.b, alpha); |
| | 329 | + noStroke(); |
| | 330 | + ellipse(0, 0, p.size, p.size); |
| | 331 | + |
| | 332 | + // Add glow |
| | 333 | + fill(p.color.r, p.color.g, p.color.b, alpha * 0.3); |
| | 334 | + ellipse(0, 0, p.size * 2, p.size * 2); |
| | 335 | + |
| | 336 | + } else if (p.type === 'spring') { |
| | 337 | + // Spring particles: green energy |
| | 338 | + fill(p.color.r, p.color.g, p.color.b, alpha); |
| | 339 | + noStroke(); |
| | 340 | + ellipse(0, 0, p.size, p.size); |
| | 341 | + } |
| | 342 | + |
| | 343 | + pop(); |
| | 344 | + } |
| | 345 | +} |
| | 346 | + |
| 213 | function drawSpringPaddleSystemsEnhanced() { | 347 | function drawSpringPaddleSystemsEnhanced() { |
| 214 | - // Draw springs with enhanced visuals | 348 | + // Draw springs with enhanced visuals and particles |
| 215 | drawSpringsEnhanced(); | 349 | drawSpringsEnhanced(); |
| 216 | | 350 | |
| 217 | // Draw paddles with glow effects | 351 | // Draw paddles with glow effects |
@@ -225,17 +359,19 @@ function drawSpringsEnhanced() { |
| 225 | // Left spring | 359 | // Left spring |
| 226 | let leftSupportPos = leftSupport.position; | 360 | let leftSupportPos = leftSupport.position; |
| 227 | let leftPaddlePos = leftPaddle.position; | 361 | let leftPaddlePos = leftPaddle.position; |
| 228 | - drawSpringLineEnhanced(leftSupportPos, leftPaddlePos); | 362 | + let leftCompression = drawSpringLineEnhanced(leftSupportPos, leftPaddlePos); |
| | 363 | + createSpringParticles(leftPaddlePos, leftCompression); |
| 229 | | 364 | |
| 230 | // Right spring | 365 | // Right spring |
| 231 | let rightSupportPos = rightSupport.position; | 366 | let rightSupportPos = rightSupport.position; |
| 232 | let rightPaddlePos = rightPaddle.position; | 367 | let rightPaddlePos = rightPaddle.position; |
| 233 | - drawSpringLineEnhanced(rightSupportPos, rightPaddlePos); | 368 | + let rightCompression = drawSpringLineEnhanced(rightSupportPos, rightPaddlePos); |
| | 369 | + createSpringParticles(rightPaddlePos, rightCompression); |
| 234 | } | 370 | } |
| 235 | | 371 | |
| 236 | function drawSpringLineEnhanced(startPos, endPos) { | 372 | function drawSpringLineEnhanced(startPos, endPos) { |
| 237 | - let segments = 10; | 373 | + let segments = 12; // More segments for smoother springs |
| 238 | - let amplitude = 8; | 374 | + let amplitude = 10; // Bigger amplitude for more dramatic effect |
| 239 | | 375 | |
| 240 | // Calculate spring compression for visual effects | 376 | // Calculate spring compression for visual effects |
| 241 | let currentLength = dist(startPos.x, startPos.y, endPos.x, endPos.y); | 377 | let currentLength = dist(startPos.x, startPos.y, endPos.x, endPos.y); |
@@ -245,7 +381,7 @@ function drawSpringLineEnhanced(startPos, endPos) { |
| 245 | // Enhanced spring glow based on compression | 381 | // Enhanced spring glow based on compression |
| 246 | let glowIntensity = 150 + compression * SPRING_GLOW_INTENSITY; | 382 | let glowIntensity = 150 + compression * SPRING_GLOW_INTENSITY; |
| 247 | stroke(0, 255, 136, glowIntensity); | 383 | stroke(0, 255, 136, glowIntensity); |
| 248 | - strokeWeight(2 + compression * 1.5); | 384 | + strokeWeight(3 + compression * 2); // Thicker when compressed |
| 249 | | 385 | |
| 250 | // Draw spring coil with smooth curves | 386 | // Draw spring coil with smooth curves |
| 251 | beginShape(); | 387 | beginShape(); |
@@ -260,7 +396,7 @@ function drawSpringLineEnhanced(startPos, endPos) { |
| 260 | if (i > 0 && i < segments) { | 396 | if (i > 0 && i < segments) { |
| 261 | let perpX = -(endPos.y - startPos.y) / currentLength; | 397 | let perpX = -(endPos.y - startPos.y) / currentLength; |
| 262 | let perpY = (endPos.x - startPos.x) / currentLength; | 398 | let perpY = (endPos.x - startPos.x) / currentLength; |
| 263 | - let offset = sin(i * PI * 1.2) * amplitude; | 399 | + let offset = sin(i * PI * 1.5) * amplitude; // More dramatic oscillation |
| 264 | x += perpX * offset; | 400 | x += perpX * offset; |
| 265 | y += perpY * offset; | 401 | y += perpY * offset; |
| 266 | } | 402 | } |
@@ -270,9 +406,10 @@ function drawSpringLineEnhanced(startPos, endPos) { |
| 270 | | 406 | |
| 271 | endShape(); | 407 | endShape(); |
| 272 | | 408 | |
| 273 | - // Add spring glow effect | 409 | + // Add spring glow effect with pulsing |
| 274 | - stroke(0, 255, 136, glowIntensity * 0.3); | 410 | + let pulse = sin(frameCount * 0.1) * 0.2 + 1; |
| 275 | - strokeWeight(6 + compression * 2); | 411 | + stroke(0, 255, 136, glowIntensity * 0.4 * pulse); |
| | 412 | + strokeWeight(8 + compression * 3); |
| 276 | beginShape(); | 413 | beginShape(); |
| 277 | noFill(); | 414 | noFill(); |
| 278 | | 415 | |
@@ -284,6 +421,8 @@ function drawSpringLineEnhanced(startPos, endPos) { |
| 284 | } | 421 | } |
| 285 | | 422 | |
| 286 | endShape(); | 423 | endShape(); |
| | 424 | + |
| | 425 | + return compression; // Return compression for particle effects |
| 287 | } | 426 | } |
| 288 | | 427 | |
| 289 | function drawPaddlesWithGlow() { | 428 | function drawPaddlesWithGlow() { |
@@ -302,28 +441,37 @@ function drawSinglePaddleEnhanced(paddle, ballDistance) { |
| 302 | let angle = paddle.angle; | 441 | let angle = paddle.angle; |
| 303 | | 442 | |
| 304 | // Calculate glow intensity based on ball proximity | 443 | // Calculate glow intensity based on ball proximity |
| 305 | - let glowIntensity = map(ballDistance, 0, PADDLE_GLOW_DISTANCE, 100, 0); | 444 | + let glowIntensity = map(ballDistance, 0, PADDLE_GLOW_DISTANCE, 150, 0); |
| 306 | - glowIntensity = constrain(glowIntensity, 0, 100); | 445 | + glowIntensity = constrain(glowIntensity, 0, 150); |
| 307 | | 446 | |
| 308 | push(); | 447 | push(); |
| 309 | translate(pos.x, pos.y); | 448 | translate(pos.x, pos.y); |
| 310 | rotate(angle); | 449 | rotate(angle); |
| 311 | | 450 | |
| 312 | - // Draw glow effect first | 451 | + // Draw enhanced glow effect first |
| 313 | if (glowIntensity > 0) { | 452 | if (glowIntensity > 0) { |
| 314 | - fill(0, 255, 136, glowIntensity * 0.5); | 453 | + fill(0, 255, 136, glowIntensity * 0.6); |
| 315 | noStroke(); | 454 | noStroke(); |
| 316 | rectMode(CENTER); | 455 | rectMode(CENTER); |
| 317 | - rect(0, 0, PADDLE_WIDTH + 8, PADDLE_HEIGHT + 8); | 456 | + rect(0, 0, PADDLE_WIDTH + 12, PADDLE_HEIGHT + 12); |
| | 457 | + |
| | 458 | + // Add outer glow |
| | 459 | + fill(0, 255, 136, glowIntensity * 0.3); |
| | 460 | + rect(0, 0, PADDLE_WIDTH + 20, PADDLE_HEIGHT + 20); |
| 318 | } | 461 | } |
| 319 | | 462 | |
| 320 | - // Draw main paddle | 463 | + // Draw main paddle with enhanced visual |
| 321 | fill(0, 255, 136); | 464 | fill(0, 255, 136); |
| 322 | - stroke(0, 255, 136, 200 + glowIntensity); | 465 | + stroke(0, 255, 136, 220 + glowIntensity * 0.5); |
| 323 | - strokeWeight(2); | 466 | + strokeWeight(3); |
| 324 | rectMode(CENTER); | 467 | rectMode(CENTER); |
| 325 | rect(0, 0, PADDLE_WIDTH, PADDLE_HEIGHT); | 468 | rect(0, 0, PADDLE_WIDTH, PADDLE_HEIGHT); |
| 326 | | 469 | |
| | 470 | + // Add core highlight |
| | 471 | + fill(150, 255, 200, 100); |
| | 472 | + noStroke(); |
| | 473 | + rect(0, 0, PADDLE_WIDTH - 4, PADDLE_HEIGHT - 4); |
| | 474 | + |
| 327 | pop(); | 475 | pop(); |
| 328 | } | 476 | } |
| 329 | | 477 | |
@@ -332,14 +480,20 @@ function drawSupportPointsEnhanced() { |
| 332 | let leftActivity = Math.abs(inputBuffer.left) * 255; | 480 | let leftActivity = Math.abs(inputBuffer.left) * 255; |
| 333 | let rightActivity = Math.abs(inputBuffer.right) * 255; | 481 | let rightActivity = Math.abs(inputBuffer.right) * 255; |
| 334 | | 482 | |
| 335 | - // Left support | 483 | + // Left support with pulsing effect |
| 336 | - fill(0, 255, 136, 100 + leftActivity * 0.5); | 484 | + let leftPulse = sin(frameCount * 0.2) * 0.3 + 1; |
| | 485 | + fill(0, 255, 136, 100 + leftActivity * 0.6); |
| 337 | noStroke(); | 486 | noStroke(); |
| 338 | - ellipse(leftSupport.position.x, leftSupport.position.y, 8 + leftActivity * 0.1, 8 + leftActivity * 0.1); | 487 | + ellipse(leftSupport.position.x, leftSupport.position.y, |
| 339 | - | 488 | + (8 + leftActivity * 0.15) * leftPulse, |
| 340 | - // Right support | 489 | + (8 + leftActivity * 0.15) * leftPulse); |
| 341 | - fill(0, 255, 136, 100 + rightActivity * 0.5); | 490 | + |
| 342 | - ellipse(rightSupport.position.x, rightSupport.position.y, 8 + rightActivity * 0.1, 8 + rightActivity * 0.1); | 491 | + // Right support with pulsing effect |
| | 492 | + let rightPulse = sin(frameCount * 0.2 + PI) * 0.3 + 1; |
| | 493 | + fill(0, 255, 136, 100 + rightActivity * 0.6); |
| | 494 | + ellipse(rightSupport.position.x, rightSupport.position.y, |
| | 495 | + (8 + rightActivity * 0.15) * rightPulse, |
| | 496 | + (8 + rightActivity * 0.15) * rightPulse); |
| 343 | } | 497 | } |
| 344 | | 498 | |
| 345 | function drawBallEnhanced() { | 499 | function drawBallEnhanced() { |
@@ -350,22 +504,35 @@ function drawBallEnhanced() { |
| 350 | // Enhanced ball with speed-based effects | 504 | // Enhanced ball with speed-based effects |
| 351 | let speedIntensity = map(speed, 0, 15, 50, 255); | 505 | let speedIntensity = map(speed, 0, 15, 50, 255); |
| 352 | | 506 | |
| 353 | - // Ball trail effect | 507 | + // Multi-layered trail effect |
| 354 | - fill(255, 100, 100, 30); | 508 | + for (let i = 0; i < 3; i++) { |
| 355 | - noStroke(); | 509 | + let offset = i * 3; |
| 356 | - ellipse(ballPos.x, ballPos.y, BALL_RADIUS * 4, BALL_RADIUS * 4); | 510 | + fill(255, 100, 100, 40 - i * 10); |
| | 511 | + noStroke(); |
| | 512 | + ellipse(ballPos.x - ballVel.x * offset * 0.1, |
| | 513 | + ballPos.y - ballVel.y * offset * 0.1, |
| | 514 | + BALL_RADIUS * (4 - i), BALL_RADIUS * (4 - i)); |
| | 515 | + } |
| 357 | | 516 | |
| 358 | - // Main ball | 517 | + // Main ball with enhanced glow |
| 359 | fill(255, 100, 100); | 518 | fill(255, 100, 100); |
| 360 | - stroke(255, 150, 150, speedIntensity); | 519 | + stroke(255, 200, 200, speedIntensity); |
| 361 | - strokeWeight(2 + speed * 0.1); | 520 | + strokeWeight(3 + speed * 0.15); |
| 362 | ellipse(ballPos.x, ballPos.y, BALL_RADIUS * 2, BALL_RADIUS * 2); | 521 | ellipse(ballPos.x, ballPos.y, BALL_RADIUS * 2, BALL_RADIUS * 2); |
| 363 | | 522 | |
| 364 | - // Speed indicator | 523 | + // Speed indicator core |
| 365 | - if (speed > 10) { | 524 | + if (speed > 8) { |
| 366 | - fill(255, 255, 255, speedIntensity * 0.5); | 525 | + fill(255, 255, 255, speedIntensity * 0.8); |
| 367 | noStroke(); | 526 | noStroke(); |
| 368 | - ellipse(ballPos.x, ballPos.y, BALL_RADIUS, BALL_RADIUS); | 527 | + ellipse(ballPos.x, ballPos.y, BALL_RADIUS * 0.8, BALL_RADIUS * 0.8); |
| | 528 | + } |
| | 529 | + |
| | 530 | + // Outer energy ring for high speeds |
| | 531 | + if (speed > 12) { |
| | 532 | + noFill(); |
| | 533 | + stroke(255, 255, 255, speedIntensity * 0.5); |
| | 534 | + strokeWeight(2); |
| | 535 | + ellipse(ballPos.x, ballPos.y, BALL_RADIUS * 3, BALL_RADIUS * 3); |
| 369 | } | 536 | } |
| 370 | } | 537 | } |
| 371 | | 538 | |
@@ -392,6 +559,7 @@ function drawDebugInfo() { |
| 392 | textSize(12); | 559 | textSize(12); |
| 393 | text(`FPS: ${Math.round(frameRate())}`, 10, 20); | 560 | text(`FPS: ${Math.round(frameRate())}`, 10, 20); |
| 394 | text(`Ball Speed: ${Math.round(getBallSpeed())}`, 10, 35); | 561 | text(`Ball Speed: ${Math.round(getBallSpeed())}`, 10, 35); |
| | 562 | + text(`Particles: ${particles.length}`, 10, 50); |
| 395 | | 563 | |
| 396 | // Enhanced spring info | 564 | // Enhanced spring info |
| 397 | let leftSpringLength = dist(leftSupport.position.x, leftSupport.position.y, | 565 | let leftSpringLength = dist(leftSupport.position.x, leftSupport.position.y, |
@@ -399,9 +567,9 @@ function drawDebugInfo() { |
| 399 | let rightSpringLength = dist(rightSupport.position.x, rightSupport.position.y, | 567 | let rightSpringLength = dist(rightSupport.position.x, rightSupport.position.y, |
| 400 | rightPaddle.position.x, rightPaddle.position.y); | 568 | rightPaddle.position.x, rightPaddle.position.y); |
| 401 | | 569 | |
| 402 | - text(`Left Spring: ${Math.round(leftSpringLength)}px`, 10, 50); | 570 | + text(`L Spring: ${Math.round(leftSpringLength)}px (${((SPRING_LENGTH/leftSpringLength - 1) * 100).toFixed(0)}%)`, 10, 65); |
| 403 | - text(`Right Spring: ${Math.round(rightSpringLength)}px`, 10, 65); | 571 | + text(`R Spring: ${Math.round(rightSpringLength)}px (${((SPRING_LENGTH/rightSpringLength - 1) * 100).toFixed(0)}%)`, 10, 80); |
| 404 | - text(`Input Buffer: L=${inputBuffer.left.toFixed(2)} R=${inputBuffer.right.toFixed(2)}`, 10, 80); | 572 | + text(`Input: L=${inputBuffer.left.toFixed(2)} R=${inputBuffer.right.toFixed(2)}`, 10, 95); |
| 405 | } | 573 | } |
| 406 | | 574 | |
| 407 | function drawStartMessage() { | 575 | function drawStartMessage() { |
@@ -410,7 +578,7 @@ function drawStartMessage() { |
| 410 | textSize(20); | 578 | textSize(20); |
| 411 | text("Press any key to start!", width/2, height/2 + 100); | 579 | text("Press any key to start!", width/2, height/2 + 100); |
| 412 | textSize(14); | 580 | textSize(14); |
| 413 | - text("Enhanced controls with smooth acceleration!", width/2, height/2 + 125); | 581 | + text("Bouncier springs, faster paddles, explosive particles!", width/2, height/2 + 125); |
| 414 | } | 582 | } |
| 415 | | 583 | |
| 416 | function resetBall() { | 584 | function resetBall() { |
@@ -492,6 +660,9 @@ function keyPressed() { |
| 492 | inputBuffer.left = 0; | 660 | inputBuffer.left = 0; |
| 493 | inputBuffer.right = 0; | 661 | inputBuffer.right = 0; |
| 494 | | 662 | |
| | 663 | + // Clear particles |
| | 664 | + particles = []; |
| | 665 | + |
| 495 | console.log("🔄 Game reset!"); | 666 | console.log("🔄 Game reset!"); |
| 496 | } | 667 | } |
| 497 | } | 668 | } |