zeroed-some/cob / 5724b53

Browse files

canvas things, attempts at silk issues

Authored by espadonne
SHA
5724b5352fb2240669a01741f1d50a0cd1805f02
Parents
ec1ef3b
Tree
8bb3db0

1 changed file

StatusFile+-
M index.html 78 44
index.htmlmodified
@@ -3,83 +3,93 @@
33
 <head>
44
     <meta charset="UTF-8">
55
     <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
-    <title>Cob - Spider Web Game</title>
6
+    <title>Cob :: Monch Fireflies</title>
77
     <script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.7.0/p5.min.js"></script>
88
     <style>
99
         body {
1010
             margin: 0;
1111
             padding: 0;
1212
             overflow: hidden;
13
-            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
14
-            display: flex;
15
-            justify-content: center;
16
-            align-items: center;
17
-            min-height: 100vh;
13
+            background: #000;
14
+            width: 100vw;
15
+            height: 100vh;
1816
             font-family: Arial, sans-serif;
1917
         }
2018
         #game-container {
21
-            position: relative;
22
-            box-shadow: 0 20px 60px rgba(0,0,0,0.3);
23
-            border-radius: 10px;
24
-            overflow: hidden;
19
+            position: fixed;
20
+            top: 0;
21
+            left: 0;
22
+            width: 100vw;
23
+            height: 100vh;
24
+        }
25
+        canvas {
26
+            display: block;
27
+            width: 100% !important;
28
+            height: 100% !important;
2529
         }
2630
         #info {
2731
             position: absolute;
28
-            top: 10px;
29
-            left: 10px;
32
+            top: 20px;
33
+            left: 20px;
3034
             color: white;
31
-            font-size: 14px;
32
-            text-shadow: 2px 2px 4px rgba(0,0,0,0.5);
35
+            font-size: 16px;
36
+            text-shadow: 2px 2px 4px rgba(0,0,0,0.8);
3337
             pointer-events: none;
3438
             z-index: 10;
39
+            background: rgba(0,0,0,0.3);
40
+            padding: 10px 15px;
41
+            border-radius: 8px;
3542
         }
3643
         #phase-indicator {
3744
             position: absolute;
38
-            top: 10px;
39
-            right: 10px;
45
+            top: 20px;
46
+            right: 20px;
4047
             color: white;
41
-            font-size: 18px;
48
+            font-size: 20px;
4249
             font-weight: bold;
43
-            text-shadow: 2px 2px 4px rgba(0,0,0,0.5);
50
+            text-shadow: 2px 2px 4px rgba(0,0,0,0.8);
4451
             pointer-events: none;
4552
             z-index: 10;
4653
             text-align: right;
54
+            background: rgba(0,0,0,0.3);
55
+            padding: 10px 15px;
56
+            border-radius: 8px;
4757
         }
4858
         #web-meter {
4959
             position: absolute;
50
-            bottom: 20px;
60
+            bottom: 30px;
5161
             left: 50%;
5262
             transform: translateX(-50%);
53
-            width: 200px;
54
-            height: 30px;
55
-            background: rgba(0,0,0,0.3);
56
-            border: 2px solid rgba(255,255,255,0.5);
57
-            border-radius: 15px;
63
+            width: 300px;
64
+            height: 40px;
65
+            background: rgba(0,0,0,0.4);
66
+            border: 3px solid rgba(255,255,255,0.6);
67
+            border-radius: 20px;
5868
             overflow: hidden;
59
-            box-shadow: 0 4px 10px rgba(0,0,0,0.3);
69
+            box-shadow: 0 4px 15px rgba(0,0,0,0.5);
6070
         }
6171
         #web-meter-fill {
6272
             height: 100%;
6373
             background: linear-gradient(90deg, #87CEEB, #E0F6FF);
6474
             transition: width 0.3s ease;
65
-            box-shadow: inset 0 0 10px rgba(255,255,255,0.5);
75
+            box-shadow: inset 0 0 15px rgba(255,255,255,0.5);
6676
         }
6777
         #web-meter-label {
6878
             position: absolute;
69
-            bottom: 55px;
79
+            bottom: 75px;
7080
             left: 50%;
7181
             transform: translateX(-50%);
7282
             color: white;
73
-            font-size: 12px;
83
+            font-size: 14px;
7484
             font-weight: bold;
75
-            text-shadow: 2px 2px 4px rgba(0,0,0,0.5);
85
+            text-shadow: 2px 2px 4px rgba(0,0,0,0.8);
7686
         }
7787
     </style>
7888
 </head>
7989
 <body>
8090
     <div id="game-container">
8191
         <div id="info">
82
-            Click to jump • Hold mouse while airborne to spin web • Space to munch!<br>
92
+            Click to jump • Space to spin web • Shift to munch!<br>
8393
             Web Strands: <span id="strand-count">0</span><br>
8494
             Flies Caught: <span id="flies-caught">0</span> | Munched: <span id="flies-munched">0</span>
8595
         </div>
@@ -101,7 +111,7 @@
101111
         let particles = [];
102112
         let isDeployingWeb = false;
103113
         let currentStrand = null;
104
-        let mouseIsPressed = false;
114
+        let spacePressed = false; // Track spacebar state
105115
         let isMunching = false;
106116
         
107117
         // Web resource management
@@ -844,7 +854,8 @@
844854
         }
845855
 
846856
         function setup() {
847
-            let canvas = createCanvas(800, 600);
857
+            // Use full viewport dimensions
858
+            let canvas = createCanvas(window.innerWidth, window.innerHeight);
848859
             canvas.parent('game-container');
849860
             
850861
             skyColor1 = color(135, 206, 235);
@@ -854,8 +865,10 @@
854865
             
855866
             spider = new Spider(width / 2, height - 50);
856867
             
857
-            // Create organic obstacles with variety
858
-            let numObstacles = 8;
868
+            // Create organic obstacles with variety - scale with viewport
869
+            let numObstacles = Math.floor((width * height) / 60000); // Scale based on area
870
+            numObstacles = constrain(numObstacles, 8, 20);
871
+            
859872
             for (let i = 0; i < numObstacles; i++) {
860873
                 let x = random(100, width - 100);
861874
                 let y = random(100, height - 150);
@@ -864,7 +877,7 @@
864877
                 
865878
                 let valid = true;
866879
                 for (let obstacle of obstacles) {
867
-                    if (dist(x, y, obstacle.x, obstacle.y) < radius + obstacle.radius + 20) {
880
+                    if (dist(x, y, obstacle.x, obstacle.y) < radius + obstacle.radius + 30) {
868881
                         valid = false;
869882
                         break;
870883
                     }
@@ -875,18 +888,29 @@
875888
                 }
876889
             }
877890
             
878
-            // Add guaranteed anchor points with specific types
891
+            // Add guaranteed anchor points with specific types - distributed across viewport
879892
             obstacles.push(new Obstacle(50, height/2, 35, 'branch'));
880893
             obstacles.push(new Obstacle(width - 50, height/2, 35, 'branch'));
881894
             obstacles.push(new Obstacle(width/2, 50, 40, 'leaf'));
882895
             obstacles.push(new Obstacle(width/4, height - 200, 30, 'leaf'));
883896
             obstacles.push(new Obstacle(3*width/4, height - 200, 30, 'branch'));
884897
             
898
+            // Add more anchor points for larger screens
899
+            if (width > 1200) {
900
+                obstacles.push(new Obstacle(width/3, height/3, 35, 'leaf'));
901
+                obstacles.push(new Obstacle(2*width/3, height/3, 35, 'branch'));
902
+            }
903
+            
885904
             // Spawn initial food boxes
886
-            for (let i = 0; i < 3; i++) {
905
+            let numBoxes = Math.max(3, Math.floor(width / 400));
906
+            for (let i = 0; i < numBoxes; i++) {
887907
                 spawnFoodBox();
888908
             }
889909
         }
910
+        
911
+        function windowResized() {
912
+            resizeCanvas(window.innerWidth, window.innerHeight);
913
+        }
890914
 
891915
         function draw() {
892916
             phaseTimer++;
@@ -1063,25 +1087,36 @@
10631087
 
10641088
         function keyPressed() {
10651089
             if (key === ' ') {
1066
-                spider.munch();
1090
+                spacePressed = true;
10671091
                 return false; // Prevent page scroll
10681092
             }
1093
+            if (keyCode === SHIFT) {
1094
+                spider.munch();
1095
+                return false;
1096
+            }
1097
+        }
1098
+        
1099
+        function keyReleased() {
1100
+            if (key === ' ') {
1101
+                spacePressed = false;
1102
+                isDeployingWeb = false;
1103
+                return false;
1104
+            }
10691105
         }
10701106
 
10711107
         function mousePressed() {
1072
-            mouseIsPressed = true;
1108
+            // Only jump on mouse press, no web deployment
10731109
             if (!spider.isAirborne) {
10741110
                 spider.jump(mouseX, mouseY);
10751111
             }
10761112
         }
10771113
 
10781114
         function mouseReleased() {
1079
-            mouseIsPressed = false;
1080
-            isDeployingWeb = false;
1115
+            // No longer needed for web deployment
10811116
         }
10821117
 
10831118
         function touchStarted() {
1084
-            mouseIsPressed = true;
1119
+            // Only jump on touch, no web deployment
10851120
             if (!spider.isAirborne) {
10861121
                 spider.jump(touches[0].x, touches[0].y);
10871122
             }
@@ -1089,8 +1124,7 @@
10891124
         }
10901125
 
10911126
         function touchEnded() {
1092
-            mouseIsPressed = false;
1093
-            isDeployingWeb = false;
1127
+            // No longer needed for web deployment
10941128
             return false;
10951129
         }
10961130
     </script>