zeroed-some/cob / 22714f1

Browse files

dont have twigs on branch

Authored by espadonne
SHA
22714f1cd361bd1b8455333c26a28bfc6121e12a
Parents
465a894
Tree
7585c2a

1 changed file

StatusFile+-
M js/game.js 21 52
js/game.jsmodified
@@ -51,35 +51,17 @@ function setup() {
5151
     let branchStartX = homeBranchSide === 'left' ? -20 : width + 20;
5252
     let branchEndX = homeBranchSide === 'left' ? homeBranchLength : width - homeBranchLength;
5353
     
54
-    // Generate twigs with FIXED positions
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
54
+    // Generate leaves with FIXED positions (simplified)
7355
     let leaves = [];
74
-    for (let i = 0; i < 5; i++) {
75
-        let t = 0.3 + (0.4 * i / 4); // Distribute between 0.3 and 0.7
56
+    for (let i = 0; i < 3; i++) {
57
+        let t = 0.3 + (0.4 * i / 2);
7658
         let x = lerp(branchStartX, branchEndX, t);
7759
         leaves.push({
78
-            x: x, // Store actual position
79
-            yOffset: -homeBranchThickness - (i * 10) + (i % 2 === 0 ? -4 : 3),
80
-            rotation: (-PI/7 + (i * PI/8)) * (homeBranchSide === 'right' ? -1 : 1),
81
-            width: 16 + (i % 2 ? 2 : -1),
82
-            height: 8 + (i % 2 ? 1 : 0)
60
+            t: t, // Store position as percentage for proper rotation
61
+            yOffset: -homeBranchThickness - 10,
62
+            rotation: random(-PI/8, PI/8),
63
+            width: 16,
64
+            height: 8
8365
         });
8466
     }
8567
     
@@ -93,15 +75,14 @@ function setup() {
9375
         });
9476
     }
9577
     
96
-    // Store home branch info for rendering
78
+    // Store home branch info for rendering (simplified)
9779
     window.homeBranch = {
9880
         side: homeBranchSide,
9981
         startX: branchStartX,
10082
         endX: branchEndX,
10183
         y: homeBranchY,
10284
         thickness: homeBranchThickness,
103
-        angle: homeBranchSide === 'left' ? 0.05 : -0.05, // Fixed slight angle
104
-        twigs: twigs,
85
+        angle: homeBranchSide === 'left' ? 0.05 : -0.05,
10586
         leaves: leaves,
10687
         barkTextures: barkTextures
10788
     };
@@ -486,33 +467,21 @@ function drawSkyGradient() {
486467
         
487468
         pop();
488469
         
489
-        // Small twigs
470
+        // Small twigs - properly attached to the rotated branch
490471
         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
-        }
511472
         
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)
513481
         for (let leaf of branch.leaves) {
482
+            let leafX = branch.startX + (branch.endX - branch.startX) * leaf.t;
514483
             push();
515
-            translate(leaf.x, branch.y + leaf.yOffset);
484
+            translate(leafX, leaf.yOffset);
516485
             rotate(leaf.rotation);
517486
             
518487
             // Leaf shadow