@@ -3,83 +3,93 @@ |
| 3 | 3 | <head> |
| 4 | 4 | <meta charset="UTF-8"> |
| 5 | 5 | <meta name="viewport" content="width=device-width, initial-scale=1.0"> |
| 6 | | - <title>Cob - Spider Web Game</title> |
| 6 | + <title>Cob :: Monch Fireflies</title> |
| 7 | 7 | <script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.7.0/p5.min.js"></script> |
| 8 | 8 | <style> |
| 9 | 9 | body { |
| 10 | 10 | margin: 0; |
| 11 | 11 | padding: 0; |
| 12 | 12 | 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; |
| 18 | 16 | font-family: Arial, sans-serif; |
| 19 | 17 | } |
| 20 | 18 | #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; |
| 25 | 29 | } |
| 26 | 30 | #info { |
| 27 | 31 | position: absolute; |
| 28 | | - top: 10px; |
| 29 | | - left: 10px; |
| 32 | + top: 20px; |
| 33 | + left: 20px; |
| 30 | 34 | 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); |
| 33 | 37 | pointer-events: none; |
| 34 | 38 | z-index: 10; |
| 39 | + background: rgba(0,0,0,0.3); |
| 40 | + padding: 10px 15px; |
| 41 | + border-radius: 8px; |
| 35 | 42 | } |
| 36 | 43 | #phase-indicator { |
| 37 | 44 | position: absolute; |
| 38 | | - top: 10px; |
| 39 | | - right: 10px; |
| 45 | + top: 20px; |
| 46 | + right: 20px; |
| 40 | 47 | color: white; |
| 41 | | - font-size: 18px; |
| 48 | + font-size: 20px; |
| 42 | 49 | 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); |
| 44 | 51 | pointer-events: none; |
| 45 | 52 | z-index: 10; |
| 46 | 53 | text-align: right; |
| 54 | + background: rgba(0,0,0,0.3); |
| 55 | + padding: 10px 15px; |
| 56 | + border-radius: 8px; |
| 47 | 57 | } |
| 48 | 58 | #web-meter { |
| 49 | 59 | position: absolute; |
| 50 | | - bottom: 20px; |
| 60 | + bottom: 30px; |
| 51 | 61 | left: 50%; |
| 52 | 62 | 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; |
| 58 | 68 | 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); |
| 60 | 70 | } |
| 61 | 71 | #web-meter-fill { |
| 62 | 72 | height: 100%; |
| 63 | 73 | background: linear-gradient(90deg, #87CEEB, #E0F6FF); |
| 64 | 74 | 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); |
| 66 | 76 | } |
| 67 | 77 | #web-meter-label { |
| 68 | 78 | position: absolute; |
| 69 | | - bottom: 55px; |
| 79 | + bottom: 75px; |
| 70 | 80 | left: 50%; |
| 71 | 81 | transform: translateX(-50%); |
| 72 | 82 | color: white; |
| 73 | | - font-size: 12px; |
| 83 | + font-size: 14px; |
| 74 | 84 | 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); |
| 76 | 86 | } |
| 77 | 87 | </style> |
| 78 | 88 | </head> |
| 79 | 89 | <body> |
| 80 | 90 | <div id="game-container"> |
| 81 | 91 | <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> |
| 83 | 93 | Web Strands: <span id="strand-count">0</span><br> |
| 84 | 94 | Flies Caught: <span id="flies-caught">0</span> | Munched: <span id="flies-munched">0</span> |
| 85 | 95 | </div> |
@@ -101,7 +111,7 @@ |
| 101 | 111 | let particles = []; |
| 102 | 112 | let isDeployingWeb = false; |
| 103 | 113 | let currentStrand = null; |
| 104 | | - let mouseIsPressed = false; |
| 114 | + let spacePressed = false; // Track spacebar state |
| 105 | 115 | let isMunching = false; |
| 106 | 116 | |
| 107 | 117 | // Web resource management |
@@ -844,7 +854,8 @@ |
| 844 | 854 | } |
| 845 | 855 | |
| 846 | 856 | function setup() { |
| 847 | | - let canvas = createCanvas(800, 600); |
| 857 | + // Use full viewport dimensions |
| 858 | + let canvas = createCanvas(window.innerWidth, window.innerHeight); |
| 848 | 859 | canvas.parent('game-container'); |
| 849 | 860 | |
| 850 | 861 | skyColor1 = color(135, 206, 235); |
@@ -854,8 +865,10 @@ |
| 854 | 865 | |
| 855 | 866 | spider = new Spider(width / 2, height - 50); |
| 856 | 867 | |
| 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 | + |
| 859 | 872 | for (let i = 0; i < numObstacles; i++) { |
| 860 | 873 | let x = random(100, width - 100); |
| 861 | 874 | let y = random(100, height - 150); |
@@ -864,7 +877,7 @@ |
| 864 | 877 | |
| 865 | 878 | let valid = true; |
| 866 | 879 | 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) { |
| 868 | 881 | valid = false; |
| 869 | 882 | break; |
| 870 | 883 | } |
@@ -875,18 +888,29 @@ |
| 875 | 888 | } |
| 876 | 889 | } |
| 877 | 890 | |
| 878 | | - // Add guaranteed anchor points with specific types |
| 891 | + // Add guaranteed anchor points with specific types - distributed across viewport |
| 879 | 892 | obstacles.push(new Obstacle(50, height/2, 35, 'branch')); |
| 880 | 893 | obstacles.push(new Obstacle(width - 50, height/2, 35, 'branch')); |
| 881 | 894 | obstacles.push(new Obstacle(width/2, 50, 40, 'leaf')); |
| 882 | 895 | obstacles.push(new Obstacle(width/4, height - 200, 30, 'leaf')); |
| 883 | 896 | obstacles.push(new Obstacle(3*width/4, height - 200, 30, 'branch')); |
| 884 | 897 | |
| 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 | + |
| 885 | 904 | // 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++) { |
| 887 | 907 | spawnFoodBox(); |
| 888 | 908 | } |
| 889 | 909 | } |
| 910 | + |
| 911 | + function windowResized() { |
| 912 | + resizeCanvas(window.innerWidth, window.innerHeight); |
| 913 | + } |
| 890 | 914 | |
| 891 | 915 | function draw() { |
| 892 | 916 | phaseTimer++; |
@@ -1063,25 +1087,36 @@ |
| 1063 | 1087 | |
| 1064 | 1088 | function keyPressed() { |
| 1065 | 1089 | if (key === ' ') { |
| 1066 | | - spider.munch(); |
| 1090 | + spacePressed = true; |
| 1067 | 1091 | return false; // Prevent page scroll |
| 1068 | 1092 | } |
| 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 | + } |
| 1069 | 1105 | } |
| 1070 | 1106 | |
| 1071 | 1107 | function mousePressed() { |
| 1072 | | - mouseIsPressed = true; |
| 1108 | + // Only jump on mouse press, no web deployment |
| 1073 | 1109 | if (!spider.isAirborne) { |
| 1074 | 1110 | spider.jump(mouseX, mouseY); |
| 1075 | 1111 | } |
| 1076 | 1112 | } |
| 1077 | 1113 | |
| 1078 | 1114 | function mouseReleased() { |
| 1079 | | - mouseIsPressed = false; |
| 1080 | | - isDeployingWeb = false; |
| 1115 | + // No longer needed for web deployment |
| 1081 | 1116 | } |
| 1082 | 1117 | |
| 1083 | 1118 | function touchStarted() { |
| 1084 | | - mouseIsPressed = true; |
| 1119 | + // Only jump on touch, no web deployment |
| 1085 | 1120 | if (!spider.isAirborne) { |
| 1086 | 1121 | spider.jump(touches[0].x, touches[0].y); |
| 1087 | 1122 | } |
@@ -1089,8 +1124,7 @@ |
| 1089 | 1124 | } |
| 1090 | 1125 | |
| 1091 | 1126 | function touchEnded() { |
| 1092 | | - mouseIsPressed = false; |
| 1093 | | - isDeployingWeb = false; |
| 1127 | + // No longer needed for web deployment |
| 1094 | 1128 | return false; |
| 1095 | 1129 | } |
| 1096 | 1130 | </script> |