@@ -51,35 +51,17 @@ function setup() { |
| 51 | let branchStartX = homeBranchSide === 'left' ? -20 : width + 20; | 51 | let branchStartX = homeBranchSide === 'left' ? -20 : width + 20; |
| 52 | let branchEndX = homeBranchSide === 'left' ? homeBranchLength : width - homeBranchLength; | 52 | let branchEndX = homeBranchSide === 'left' ? homeBranchLength : width - homeBranchLength; |
| 53 | | 53 | |
| 54 | - // Generate twigs with FIXED positions | 54 | + // Generate leaves with FIXED positions (simplified) |
| 55 | - let twigs = []; | | |
| 56 | - let numTwigs = 7; | | |
| 57 | - for (let i = 0; i < numTwigs; i++) { | | |
| 58 | - let t = 0.2 + (0.6 * i / (numTwigs - 1)); // Evenly distributed | | |
| 59 | - let x = lerp(branchStartX, branchEndX, t); // Calculate actual X position | | |
| 60 | - twigs.push({ | | |
| 61 | - x: x, // Store actual position, not percentage | | |
| 62 | - length: 20 + (i * 4), // Vary length slightly | | |
| 63 | - angle: (-PI/4 + (i * PI/20)) * (homeBranchSide === 'right' ? -1 : 1), | | |
| 64 | - subTwigs: [ | | |
| 65 | - { pos: 0.65, length: 6, angle: -6 }, | | |
| 66 | - { pos: 0.45, length: 5, angle: 5 }, | | |
| 67 | - { pos: 0.8, length: 4, angle: -3 } | | |
| 68 | - ] | | |
| 69 | - }); | | |
| 70 | - } | | |
| 71 | - | | |
| 72 | - // Generate leaves with FIXED positions | | |
| 73 | let leaves = []; | 55 | let leaves = []; |
| 74 | - for (let i = 0; i < 5; i++) { | 56 | + for (let i = 0; i < 3; i++) { |
| 75 | - let t = 0.3 + (0.4 * i / 4); // Distribute between 0.3 and 0.7 | 57 | + let t = 0.3 + (0.4 * i / 2); |
| 76 | let x = lerp(branchStartX, branchEndX, t); | 58 | let x = lerp(branchStartX, branchEndX, t); |
| 77 | leaves.push({ | 59 | leaves.push({ |
| 78 | - x: x, // Store actual position | 60 | + t: t, // Store position as percentage for proper rotation |
| 79 | - yOffset: -homeBranchThickness - (i * 10) + (i % 2 === 0 ? -4 : 3), | 61 | + yOffset: -homeBranchThickness - 10, |
| 80 | - rotation: (-PI/7 + (i * PI/8)) * (homeBranchSide === 'right' ? -1 : 1), | 62 | + rotation: random(-PI/8, PI/8), |
| 81 | - width: 16 + (i % 2 ? 2 : -1), | 63 | + width: 16, |
| 82 | - height: 8 + (i % 2 ? 1 : 0) | 64 | + height: 8 |
| 83 | }); | 65 | }); |
| 84 | } | 66 | } |
| 85 | | 67 | |
@@ -93,15 +75,14 @@ function setup() { |
| 93 | }); | 75 | }); |
| 94 | } | 76 | } |
| 95 | | 77 | |
| 96 | - // Store home branch info for rendering | 78 | + // Store home branch info for rendering (simplified) |
| 97 | window.homeBranch = { | 79 | window.homeBranch = { |
| 98 | side: homeBranchSide, | 80 | side: homeBranchSide, |
| 99 | startX: branchStartX, | 81 | startX: branchStartX, |
| 100 | endX: branchEndX, | 82 | endX: branchEndX, |
| 101 | y: homeBranchY, | 83 | y: homeBranchY, |
| 102 | thickness: homeBranchThickness, | 84 | thickness: homeBranchThickness, |
| 103 | - angle: homeBranchSide === 'left' ? 0.05 : -0.05, // Fixed slight angle | 85 | + angle: homeBranchSide === 'left' ? 0.05 : -0.05, |
| 104 | - twigs: twigs, | | |
| 105 | leaves: leaves, | 86 | leaves: leaves, |
| 106 | barkTextures: barkTextures | 87 | barkTextures: barkTextures |
| 107 | }; | 88 | }; |
@@ -486,33 +467,21 @@ function drawSkyGradient() { |
| 486 | | 467 | |
| 487 | pop(); | 468 | pop(); |
| 488 | | 469 | |
| 489 | - // Small twigs | 470 | + // Small twigs - properly attached to the rotated branch |
| 490 | stroke(gamePhase === 'NIGHT' ? color(40, 20, 0) : color(101, 67, 33)); | 471 | stroke(gamePhase === 'NIGHT' ? color(40, 20, 0) : color(101, 67, 33)); |
| 491 | - for (let twig of branch.twigs) { | | |
| 492 | - push(); | | |
| 493 | - translate(twig.x, branch.y); | | |
| 494 | - rotate(twig.angle); | | |
| 495 | - | | |
| 496 | - // Main twig | | |
| 497 | - strokeWeight(3); | | |
| 498 | - line(0, 0, twig.length, 0); | | |
| 499 | - | | |
| 500 | - // Sub twigs | | |
| 501 | - strokeWeight(1); | | |
| 502 | - for (let subTwig of twig.subTwigs) { | | |
| 503 | - push(); | | |
| 504 | - translate(twig.length * subTwig.pos, 0); | | |
| 505 | - rotate(subTwig.angle * 0.1); | | |
| 506 | - line(0, 0, subTwig.length, -subTwig.angle); | | |
| 507 | - pop(); | | |
| 508 | - } | | |
| 509 | - pop(); | | |
| 510 | - } | | |
| 511 | | 472 | |
| 512 | - // Add leaves | 473 | + // Just add a couple simple twigs for visual interest |
| | 474 | + strokeWeight(3); |
| | 475 | + line(branch.startX + (branch.endX - branch.startX) * 0.3, -5, |
| | 476 | + branch.startX + (branch.endX - branch.startX) * 0.3 - 10, -15); |
| | 477 | + line(branch.startX + (branch.endX - branch.startX) * 0.6, 0, |
| | 478 | + branch.startX + (branch.endX - branch.startX) * 0.6 + 8, -12); |
| | 479 | + |
| | 480 | + // Add leaves (properly positioned within rotated branch) |
| 513 | for (let leaf of branch.leaves) { | 481 | for (let leaf of branch.leaves) { |
| | 482 | + let leafX = branch.startX + (branch.endX - branch.startX) * leaf.t; |
| 514 | push(); | 483 | push(); |
| 515 | - translate(leaf.x, branch.y + leaf.yOffset); | 484 | + translate(leafX, leaf.yOffset); |
| 516 | rotate(leaf.rotation); | 485 | rotate(leaf.rotation); |
| 517 | | 486 | |
| 518 | // Leaf shadow | 487 | // Leaf shadow |