phantom web fix, balloon rethink
- SHA
5bc00e6d2a1624a86c15700be5602f9bc03d53b6- Parents
-
92578dd - Tree
de13afb
5bc00e6
5bc00e6d2a1624a86c15700be5602f9bc03d53b692578dd
de13afb| Status | File | + | - |
|---|---|---|---|
| M |
js/entities.js
|
83 | 16 |
| M |
js/game.js
|
59 | 15 |
js/entities.jsmodified@@ -333,25 +333,92 @@ class Spider { | |||
| 333 | this.land() | 333 | this.land() |
| 334 | } | 334 | } |
| 335 | 335 | ||
| 336 | - land () { | 336 | + land() { |
| 337 | - this.vel.mult(0) | 337 | + this.vel.mult(0); |
| 338 | - this.isAirborne = false | 338 | + this.isAirborne = false; |
| 339 | - this.canJump = true | 339 | + this.canJump = true; |
| 340 | + | ||
| 341 | + // FIX: Check if we're actually landing on something valid | ||
| 342 | + let landedOnSomething = false; | ||
| 343 | + | ||
| 344 | + // Check if on ground | ||
| 345 | + if (this.pos.y >= height - this.radius - 5) { | ||
| 346 | + landedOnSomething = true; | ||
| 347 | + } | ||
| 348 | + | ||
| 349 | + // Check if on an obstacle | ||
| 350 | + for (let obstacle of obstacles) { | ||
| 351 | + if (this.checkObstacleCollision(obstacle)) { | ||
| 352 | + landedOnSomething = true; | ||
| 353 | + break; | ||
| 354 | + } | ||
| 355 | + } | ||
| 356 | + | ||
| 357 | + // Check if on a web strand | ||
| 358 | + for (let strand of webStrands) { | ||
| 359 | + if (strand !== currentStrand && !strand.broken && this.checkStrandCollision(strand)) { | ||
| 360 | + landedOnSomething = true; | ||
| 361 | + break; | ||
| 362 | + } | ||
| 363 | + } | ||
| 364 | + | ||
| 365 | + // Check if on home branch | ||
| 366 | + if (window.homeBranch) { | ||
| 367 | + let branch = window.homeBranch; | ||
| 368 | + let branchStart = Math.min(branch.startX, branch.endX); | ||
| 369 | + let branchEnd = Math.max(branch.startX, branch.endX); | ||
| 370 | + | ||
| 371 | + if (this.pos.x >= branchStart - 10 && this.pos.x <= branchEnd + 10) { | ||
| 372 | + let t = (this.pos.x - branchStart) / (branchEnd - branchStart); | ||
| 373 | + t = constrain(t, 0, 1); | ||
| 374 | + let branchTopThickness = lerp(branch.thickness * 0.9, branch.thickness * 0.35, t); | ||
| 375 | + let branchSurfaceY = branch.y - branchTopThickness; | ||
| 376 | + let angleCorrection = (this.pos.x - branchStart) * branch.angle; | ||
| 377 | + branchSurfaceY += angleCorrection; | ||
| 378 | + | ||
| 379 | + if (abs(this.pos.y - branchSurfaceY) < this.radius + 10) { | ||
| 380 | + landedOnSomething = true; | ||
| 381 | + } | ||
| 382 | + } | ||
| 383 | + } | ||
| 384 | + | ||
| 385 | + // FIX: If we're deploying web but didn't land on anything valid, destroy the web | ||
| 386 | + if (currentStrand && isDeployingWeb && (spacePressed || touchHolding)) { | ||
| 387 | + if (landedOnSomething) { | ||
| 388 | + // Valid landing - finalize the web | ||
| 389 | + currentStrand.end = this.pos.copy(); | ||
| 390 | + if (!currentStrand.path || currentStrand.path.length === 0) { | ||
| 391 | + currentStrand.path = [this.pos.copy()]; | ||
| 392 | + } else { | ||
| 393 | + currentStrand.path.push(this.pos.copy()); | ||
| 394 | + } | ||
| 395 | + webNodes.push(new WebNode(this.pos.x, this.pos.y)); | ||
| 396 | + } else { | ||
| 397 | + // Invalid landing in mid-air - destroy the web! | ||
| 398 | + if (webStrands.length > 0 && webStrands[webStrands.length - 1] === currentStrand) { | ||
| 399 | + webStrands.pop(); // Remove the invalid strand | ||
| 400 | + | ||
| 401 | + // Create poof particles | ||
| 402 | + for (let i = 0; i < 8; i++) { | ||
| 403 | + let p = new Particle(this.pos.x, this.pos.y); | ||
| 404 | + p.color = color(255, 255, 255, 150); | ||
| 405 | + p.vel = createVector(random(-3, 3), random(-3, 3)); | ||
| 406 | + p.size = 4; | ||
| 407 | + particles.push(p); | ||
| 408 | + } | ||
| 409 | + | ||
| 410 | + // Notification | ||
| 411 | + if (notifications.length < 3) { | ||
| 412 | + notifications.push(new Notification("Web needs anchor point!", color(255, 150, 150))); | ||
| 413 | + } | ||
| 414 | + } | ||
| 415 | + } | ||
| 416 | + } | ||
| 340 | 417 | ||
| 341 | - if (currentStrand && isDeployingWeb && (spacePressed || touchHolding)) { | 418 | + currentStrand = null; |
| 342 | - // Ensure the strand has a valid end and a final node on landing | 419 | + isDeployingWeb = false; |
| 343 | - currentStrand.end = this.pos.copy() | ||
| 344 | - if (!currentStrand.path || currentStrand.path.length === 0) { | ||
| 345 | - currentStrand.path = [this.pos.copy()] | ||
| 346 | - } else { | ||
| 347 | - currentStrand.path.push(this.pos.copy()) | ||
| 348 | - } | ||
| 349 | - webNodes.push(new WebNode(this.pos.x, this.pos.y)) | ||
| 350 | } | 420 | } |
| 351 | 421 | ||
| 352 | - currentStrand = null | ||
| 353 | - isDeployingWeb = false | ||
| 354 | - } | ||
| 355 | 422 | ||
| 356 | display () { | 423 | display () { |
| 357 | push() | 424 | push() |
js/game.jsmodified@@ -2764,12 +2764,32 @@ function keyPressed () { | |||
| 2764 | } | 2764 | } |
| 2765 | } | 2765 | } |
| 2766 | 2766 | ||
| 2767 | -function keyReleased () { | 2767 | +function keyReleased() { |
| 2768 | - if (key === ' ') { | 2768 | + if (key === ' ') { |
| 2769 | - spacePressed = false | 2769 | + spacePressed = false; |
| 2770 | - isDeployingWeb = false | 2770 | + |
| 2771 | - return false | 2771 | + // FIX: Check if web is floating when released |
| 2772 | - } | 2772 | + if (isDeployingWeb && currentStrand && spider.isAirborne) { |
| 2773 | + // Spider is still airborne - this would create a floating web | ||
| 2774 | + // Remove the incomplete strand | ||
| 2775 | + if (webStrands.length > 0 && webStrands[webStrands.length - 1] === currentStrand) { | ||
| 2776 | + webStrands.pop(); | ||
| 2777 | + | ||
| 2778 | + // Poof effect | ||
| 2779 | + for (let i = 0; i < 5; i++) { | ||
| 2780 | + let p = new Particle(spider.pos.x, spider.pos.y); | ||
| 2781 | + p.color = color(255, 200, 200, 100); | ||
| 2782 | + p.vel = createVector(random(-2, 2), random(-2, 2)); | ||
| 2783 | + p.size = 3; | ||
| 2784 | + particles.push(p); | ||
| 2785 | + } | ||
| 2786 | + } | ||
| 2787 | + } | ||
| 2788 | + | ||
| 2789 | + isDeployingWeb = false; | ||
| 2790 | + currentStrand = null; | ||
| 2791 | + return false; | ||
| 2792 | + } | ||
| 2773 | } | 2793 | } |
| 2774 | 2794 | ||
| 2775 | function mousePressed () { | 2795 | function mousePressed () { |
@@ -2919,15 +2939,39 @@ function touchMoved () { | |||
| 2919 | return false // Prevent default | 2939 | return false // Prevent default |
| 2920 | } | 2940 | } |
| 2921 | 2941 | ||
| 2922 | -function touchEnded () { | 2942 | +function touchEnded() { |
| 2923 | - touchHolding = false | 2943 | + touchHolding = false; |
| 2924 | - | 2944 | + touchProcessing = false; |
| 2925 | - // Stop web deployment when releasing touch | 2945 | + |
| 2926 | - if (isDeployingWeb && spider.isAirborne) { | 2946 | + // Power jump handling... |
| 2927 | - isDeployingWeb = false | 2947 | + if (chargingJump && !spider.isAirborne) { |
| 2928 | - } | 2948 | + // ... existing power jump code ... |
| 2929 | - | 2949 | + } |
| 2930 | - return false // Prevent default | 2950 | + chargingJump = false; |
| 2951 | + jumpChargeTime = 0; | ||
| 2952 | + | ||
| 2953 | + // FIX: Check if web is floating when touch released | ||
| 2954 | + if (isDeployingWeb && currentStrand && spider.isAirborne) { | ||
| 2955 | + // Spider is still airborne - this would create a floating web | ||
| 2956 | + // Remove the incomplete strand | ||
| 2957 | + if (webStrands.length > 0 && webStrands[webStrands.length - 1] === currentStrand) { | ||
| 2958 | + webStrands.pop(); | ||
| 2959 | + | ||
| 2960 | + // Poof effect | ||
| 2961 | + for (let i = 0; i < 5; i++) { | ||
| 2962 | + let p = new Particle(spider.pos.x, spider.pos.y); | ||
| 2963 | + p.color = color(255, 200, 200, 100); | ||
| 2964 | + p.vel = createVector(random(-2, 2), random(-2, 2)); | ||
| 2965 | + p.size = 3; | ||
| 2966 | + particles.push(p); | ||
| 2967 | + } | ||
| 2968 | + } | ||
| 2969 | + } | ||
| 2970 | + | ||
| 2971 | + isDeployingWeb = false; | ||
| 2972 | + currentStrand = null; | ||
| 2973 | + | ||
| 2974 | + return false; | ||
| 2931 | } | 2975 | } |
| 2932 | 2976 | ||
| 2933 | function windowResized () { | 2977 | function windowResized () { |