zeroed-some/cob / db1e11e

Browse files

undisclosed updates

Authored by mfwolffe <wolffemf@dukes.jmu.edu>
SHA
db1e11ea17331e53dc5b54044b57cf0f6ba97399
Parents
054467b
Tree
cc20753

2 changed files

StatusFile+-
M js/entities.js 311 233
M js/game.js 53 12
js/entities.jsmodified
@@ -968,6 +968,12 @@ class Obstacle {
968968
     this.bobSpeed = random(0.02, 0.04)
969969
     this.bobAmount = 0
970970
 
971
+    // Wind effect properties
972
+    this.windSway = 0 // Current sway amount
973
+    this.windSwayTarget = 0 // Target sway for smooth animation
974
+    this.windBob = 0 // Additional vertical movement from wind
975
+    this.basketSwing = 0 // For balloon basket swinging
976
+
971977
     // Type-specific initialization
972978
     if (this.type === 'balloon') {
973979
       this.bobAmount = 8 // Balloons bob more
@@ -1006,6 +1012,57 @@ class Obstacle {
10061012
     let bob = sin(frameCount * this.bobSpeed + this.bobOffset) * this.bobAmount
10071013
     this.y = this.originalY + bob
10081014
 
1015
+    // ENHANCED: Apply wind effects
1016
+    if (windActive) {
1017
+      // Different wind responses by type
1018
+      if (this.type === 'balloon') {
1019
+        // Balloons are highly affected by wind
1020
+        this.windSwayTarget = cos(windDirection) * windStrength * 15 // Strong horizontal push
1021
+        this.windBob =
1022
+          sin(frameCount * 0.04 + this.bobOffset) * windStrength * 3 // Extra vertical movement
1023
+
1024
+        // Basket swings opposite to balloon movement (pendulum effect)
1025
+        this.basketSwing =
1026
+          -this.windSway * 0.5 + sin(frameCount * 0.06) * windStrength * 0.3
1027
+
1028
+        // Actually move the balloon
1029
+        this.originalX += cos(windDirection) * windStrength * 0.08
1030
+
1031
+        // Keep on screen with stronger resistance at edges
1032
+        if (this.originalX < 50) {
1033
+          this.originalX = 50
1034
+          this.windSwayTarget *= -0.5 // Bounce back effect
1035
+        }
1036
+        if (this.originalX > width - 50) {
1037
+          this.originalX = width - 50
1038
+          this.windSwayTarget *= -0.5
1039
+        }
1040
+      } else if (this.type === 'beetle') {
1041
+        // Beetles resist but still affected
1042
+        this.windSwayTarget = cos(windDirection) * windStrength * 3
1043
+        // Fight against wind
1044
+        this.driftAngle -= cos(windDirection) * windStrength * 0.01
1045
+      } else if (this.type === 'leaf') {
1046
+        // Leaves flutter in wind
1047
+        this.windSwayTarget = cos(windDirection) * windStrength * 5
1048
+        this.rotation += windStrength * 0.02 // Spin faster
1049
+      }
1050
+    } else {
1051
+      // No wind, return to normal
1052
+      this.windSwayTarget = 0
1053
+      this.windBob = 0
1054
+      this.basketSwing = 0
1055
+    }
1056
+
1057
+    // Smooth sway animation
1058
+    this.windSway = lerp(this.windSway, this.windSwayTarget, 0.1)
1059
+
1060
+    // Apply wind sway to position
1061
+    this.x = this.originalX + this.windSway
1062
+
1063
+    // Apply wind bob to vertical position
1064
+    this.y = this.originalY + bob + this.windBob
1065
+
10091066
     // Beetle-specific drift
10101067
     if (this.type === 'beetle') {
10111068
       // Store initial position if not set
@@ -1210,6 +1267,11 @@ class Obstacle {
12101267
     // ============================================
12111268
     push()
12121269
     
1270
+    // ENHANCED: Tilt balloon based on wind
1271
+    if (windActive) {
1272
+      rotate(this.windSway * 0.01)  // Slight tilt in wind direction
1273
+    }
1274
+
12131275
     // Balloon shadow
12141276
     noStroke()
12151277
     fill(0, 0, 0, 30)
@@ -1370,10 +1432,15 @@ class Obstacle {
13701432
 
13711433
     pop()
13721434
 
1373
-      // BIGGER, MORE DETAILED BASKET
1435
+    // BIGGER, MORE DETAILED BASKET WITH SWING
13741436
     push()
13751437
     translate(0, this.radius + 25)
13761438
     
1439
+    // ENHANCED: Apply basket swing
1440
+    if (windActive) {
1441
+      rotate(this.basketSwing * 0.02)
1442
+    }
1443
+
13771444
     // Basket shadow
13781445
     noStroke()
13791446
     fill(0, 0, 0, 20)
@@ -1414,6 +1481,11 @@ class Obstacle {
14141481
     push()
14151482
     translate(0, this.radius + 28)
14161483
     
1484
+    // ENHANCED: Ant holds on tighter in wind
1485
+    if (windActive) {
1486
+      rotate(-this.basketSwing * 0.01)  // Ant leans opposite to basket
1487
+    }
1488
+
14171489
     // Ant body
14181490
     fill(20)
14191491
     noStroke()
@@ -1454,6 +1526,12 @@ class Obstacle {
14541526
     // Sandbags hanging from basket (optional detail)
14551527
     push()
14561528
     translate(0, this.radius + 25)
1529
+    
1530
+    // ENHANCED: Sandbags swing in wind
1531
+    if (windActive) {
1532
+      rotate(this.basketSwing * 0.03)
1533
+    }
1534
+    
14571535
     fill(80, 60, 40)
14581536
     noStroke()
14591537
     ellipse(-12, 10, 4, 5)
js/game.jsmodified
@@ -879,30 +879,65 @@ function draw () {
879879
 
880880
   // PHASE 4B: Apply wind to airborne entities
881881
   if (windActive) {
882
-    // Push spider if airborne
882
+    // Push spider if airborne - MORE DRAMATIC
883883
     if (spider.isAirborne) {
884
-      spider.vel.x += cos(windDirection) * windStrength * 0.1
884
+      spider.vel.x += cos(windDirection) * windStrength * 0.15 // Increased from 0.1
885
+      spider.vel.y += sin(frameCount * 0.05) * windStrength * 0.03 // Add vertical wobble
885886
     }
886887
 
887
-    // Push flies
888
+    // Push flies - MORE VISIBLE
888889
     for (let fly of flies) {
889890
       if (!fly.stuck && !fly.caught) {
890
-        fly.vel.x += cos(windDirection) * windStrength * 0.05
891
+        fly.vel.x += cos(windDirection) * windStrength * 0.08 // Increased from 0.05
892
+        fly.vel.y += sin(frameCount * 0.1 + fly.wingPhase) * windStrength * 0.02 // Turbulence
891893
       }
892894
     }
893895
 
894
-    // Make webs sway
896
+    // ENHANCED: Make webs sway and stretch
895897
     for (let strand of webStrands) {
896898
       if (!strand.broken) {
897
-        strand.vibrate(windStrength * 0.5)
899
+        // Stronger vibration
900
+        strand.vibrate(windStrength * 0.8) // Increased from 0.5
901
+
902
+        // Apply lateral force to web path points for realistic sway
903
+        if (strand.path && strand.path.length > 2) {
904
+          for (let i = 1; i < strand.path.length - 1; i++) {
905
+            let point = strand.path[i]
906
+            // Middle points sway more than ends
907
+            let swayFactor = sin((i / strand.path.length) * PI)
908
+            point.x += cos(windDirection) * windStrength * swayFactor * 0.3
909
+            // Add some vertical movement too
910
+            point.y +=
911
+              sin(frameCount * 0.08 + i * 0.1) *
912
+              windStrength *
913
+              swayFactor *
914
+              0.15
915
+          }
916
+        }
917
+
898918
         // Check if strand is overstretched and should break
899
-        if (strand.tension > 1.2 && windStrength > 3) {
900
-          if (random() < 0.01) {
901
-            // Small chance per frame
919
+        if (strand.tension > 1.0 && windStrength > 4) {
920
+          // Lowered from 1.2
921
+          if (random() < (0.02 * windStrength) / 5) {
922
+            // Increased chance based on wind strength
902923
             strand.broken = true
903924
             notifications.push(
904925
               new Notification('Wind snapped a web!', color(255, 150, 100))
905926
             )
927
+            // Add dramatic snap particles
928
+            for (let j = 0; j < 8; j++) {
929
+              let p = new Particle(
930
+                strand.path[Math.floor(strand.path.length / 2)].x,
931
+                strand.path[Math.floor(strand.path.length / 2)].y
932
+              )
933
+              p.vel = createVector(
934
+                cos(windDirection) * random(3, 6),
935
+                random(-2, 2)
936
+              )
937
+              p.color = color(255, 255, 255)
938
+              p.size = random(2, 5)
939
+              particles.push(p)
940
+            }
906941
           }
907942
         }
908943
       }
@@ -1739,16 +1774,22 @@ function spawnThiefBird () {
17391774
 function startWindGust () {
17401775
   windActive = true
17411776
   windDirection = random() < 0.5 ? 0 : PI // Left or right
1742
-  windStrength = random(2, 5) // Variable strength
1777
+  windStrength = random(3, 6)  // Increased from (2, 5)
17431778
   windDuration = random(300, 600) // 5-10 seconds
17441779
   windTimer = 0
17451780
   windParticles = []
17461781
 
1747
-  // Notification
1782
+  // More dramatic notification
17481783
   let direction = windDirection === 0 ? '→' : '←'
1784
+  let intensity = windStrength > 4.5 ? 'Strong' : windStrength > 3.5 ? 'Moderate' : 'Light'
17491785
   notifications.push(
1750
-    new Notification(`Wind gust ${direction}`, color(200, 200, 255))
1786
+    new Notification(`${intensity} wind gust ${direction}`, color(200, 200, 255))
17511787
   )
1788
+  
1789
+  // Screen shake for strong winds
1790
+  if (windStrength > 4.5) {
1791
+    screenShake = 5
1792
+  }
17521793
 }
17531794
 
17541795
 function updateWind () {