/* * Source Code (.pde / .php): MIT License; Documents & Open Data: CC0 1.0 Universal; * Copyright (c) 2026 Jan Bühring & Adaptive Intelligence Synthesis Network (Google AI). * * Project Database: https://xqskys.de * Framework: DTIM-ZEC Modular Physics Framework (DAMTP Academic Standard) * Compatibility: Processing 4.5.7 (Java) & processing.min.js (Web Canvas) */ // ============================================================================ // 1. GLOBAL CONFIGURATION & ACCESSIBILITY STATE // ============================================================================ boolean a11yMode = false; // Probe (Player) Physics State float shipX, shipY; float shipVX, shipVY; float shipAngle; float fuel = 100.0; int cargoCount = 0; int cargoCapacity = 5; int deliveredTotal = 0; int stationLevel = 1; boolean tractorActive = false; // Station & Guinea Pig Habitat State float stationX, stationY; float stationRadius = 72.0; float pigX, pigY; float pigBob = 0.0; String pigSpeech = "Wheek! Bereit für Proviant."; int speechTimer = 240; // Game Entities int NUM_ASTEROIDS = 10; float[] astX = new float[NUM_ASTEROIDS]; float[] astY = new float[NUM_ASTEROIDS]; float[] astVX = new float[NUM_ASTEROIDS]; float[] astVY = new float[NUM_ASTEROIDS]; float[] astR = new float[NUM_ASTEROIDS]; float[] astAngle = new float[NUM_ASTEROIDS]; float[] astSpin = new float[NUM_ASTEROIDS]; int NUM_ITEMS = 12; float[] itemX = new float[NUM_ITEMS]; float[] itemY = new float[NUM_ITEMS]; float[] itemVX = new float[NUM_ITEMS]; float[] itemVY = new float[NUM_ITEMS]; int[] itemType = new int[NUM_ITEMS]; // 0 = Gurke, 1 = Quanten-Pellet, 2 = Kraut boolean[] itemActive = new boolean[NUM_ITEMS]; // Background Stars (Static subtle layout) int NUM_STARS = 45; float[] starX = new float[NUM_STARS]; float[] starY = new float[NUM_STARS]; float[] starSize = new float[NUM_STARS]; // Input Controls boolean keyUp = false; boolean keyDown = false; boolean keyLeft = false; boolean keyRight = false; // ============================================================================ // 2. INITIALIZATION (DAMTP MODULAR SETUP) // ============================================================================ void setup() { size(960, 640); smooth(); textFont(createFont("SansSerif", 14)); stationX = width * 0.5; stationY = height * 0.5; pigX = stationX; pigY = stationY + 8; resetShip(); initStars(); initAsteroids(); initItems(); } void resetShip() { shipX = stationX; shipY = stationY - stationRadius - 45; shipVX = 0.0; shipVY = 0.0; shipAngle = -HALF_PI; fuel = 100.0; } void initStars() { for (int i = 0; i < NUM_STARS; i++) { starX[i] = random(width); starY[i] = random(height); starSize[i] = random(1.2, 2.6); } } void initAsteroids() { for (int i = 0; i < NUM_ASTEROIDS; i++) { spawnAsteroid(i); } } void spawnAsteroid(int idx) { float angle = random(TWO_PI); float distFromCenter = random(200, 440); astX[idx] = stationX + cos(angle) * distFromCenter; astY[idx] = stationY + sin(angle) * distFromCenter; astVX[idx] = random(-0.45, 0.45); astVY[idx] = random(-0.45, 0.45); astR[idx] = random(18, 36); astAngle[idx] = random(TWO_PI); astSpin[idx] = random(-0.012, 0.012); } void initItems() { for (int i = 0; i < NUM_ITEMS; i++) { spawnItem(i); } } void spawnItem(int idx) { float angle = random(TWO_PI); float distFromCenter = random(140, 420); itemX[idx] = constrain(stationX + cos(angle) * distFromCenter, 40, width - 40); itemY[idx] = constrain(stationY + sin(angle) * distFromCenter, 60, height - 40); itemVX[idx] = random(-0.2, 0.2); itemVY[idx] = random(-0.2, 0.2); itemType[idx] = int(random(3)); itemActive[idx] = true; } // ============================================================================ // 3. MAIN SIMULATION LOOP // ============================================================================ void draw() { drawBackground(); updatePhysics(); drawStationAndPig(); drawItems(); drawAsteroids(); drawShip(); drawHUD(); } // ============================================================================ // 4. PHYSICS & DTIM-ZEC KINEMATICS // ============================================================================ void updatePhysics() { // Ship rotation & relaxed thrust if (keyLeft) shipAngle -= 0.048; if (keyRight) shipAngle += 0.048; if (keyUp && fuel > 0) { shipVX += cos(shipAngle) * 0.09; shipVY += sin(shipAngle) * 0.09; fuel = max(0, fuel - 0.04); } if (keyDown && fuel > 0) { shipVX -= cos(shipAngle) * 0.045; shipVY -= sin(shipAngle) * 0.045; fuel = max(0, fuel - 0.02); } // Gentle space damping for relaxed ("gemütlich") handling shipVX *= 0.985; shipVY *= 0.985; // Speed cap float speed = dist(0, 0, shipVX, shipVY); if (speed > 4.2) { shipVX = (shipVX / speed) * 4.2; shipVY = (shipVY / speed) * 4.2; } shipX += shipVX; shipY += shipVY; // Screen wrap-around if (shipX < 0) shipX += width; if (shipX > width) shipX -= width; if (shipY < 0) shipY += height; if (shipY > height) shipY -= height; // Check Station Docking & Delivery float distToStation = dist(shipX, shipY, stationX, stationY); if (distToStation < stationRadius + 24) { // Refuel gently near station fuel = min(100.0, fuel + 0.35); // Unload cargo if (cargoCount > 0) { deliveredTotal += cargoCount; cargoCount = 0; stationLevel = 1 + (deliveredTotal / 8); cargoCapacity = 5 + (stationLevel - 1) * 2; triggerPigReaction(); } } // Update Asteroids (gentle drift, avoiding station core) for (int i = 0; i < NUM_ASTEROIDS; i++) { astX[i] += astVX[i]; astY[i] += astVY[i]; astAngle[i] += astSpin[i]; if (astX[i] < -40) astX[i] += width + 80; if (astX[i] > width + 40) astX[i] -= width + 80; if (astY[i] < -40) astY[i] += height + 80; if (astY[i] > height + 40) astY[i] -= height + 80; // Soft deflection field around Habitat Dome float dStation = dist(astX[i], astY[i], stationX, stationY); if (dStation < stationRadius + astR[i] + 25) { float pushAngle = atan2(astY[i] - stationY, astX[i] - stationX); astVX[i] = cos(pushAngle) * 0.5; astVY[i] = sin(pushAngle) * 0.5; } // Soft bump with Ship (no harsh game over, just gentle bounce) float dShip = dist(astX[i], astY[i], shipX, shipY); if (dShip < astR[i] + 14) { float bounceAngle = atan2(shipY - astY[i], shipX - astX[i]); shipVX = cos(bounceAngle) * 2.2; shipVY = sin(bounceAngle) * 2.2; } } // Update Items & Tractor Beam for (int i = 0; i < NUM_ITEMS; i++) { if (!itemActive[i]) { spawnItem(i); continue; } itemX[i] += itemVX[i]; itemY[i] += itemVY[i]; if (itemX[i] < 20 || itemX[i] > width - 20) itemVX[i] *= -1; if (itemY[i] < 50 || itemY[i] > height - 20) itemVY[i] *= -1; float dShip = dist(itemX[i], itemY[i], shipX, shipY); // Tractor beam pull if (tractorActive && cargoCount < cargoCapacity && dShip < 135) { float pullAngle = atan2(shipY - itemY[i], shipX - itemX[i]); itemX[i] += cos(pullAngle) * 2.8; itemY[i] += sin(pullAngle) * 2.8; } // Collect item if (dShip < 20 && cargoCount < cargoCapacity) { cargoCount++; itemActive[i] = false; } } // Update Guinea Pig animation & speech timer pigBob += 0.06; if (speechTimer > 0) { speechTimer--; } } void triggerPigReaction() { int r = int(random(4)); if (r == 0) pigSpeech = "WHEEK! Frische Raum-Gurke!"; else if (r == 1) pigSpeech = "Mampf... Quanten-Heu schmeckt!"; else if (r == 2) pigSpeech = "Wheek-Wheek! Kuppel-Level " + stationLevel + "!"; else pigSpeech = "Zufriedenes Quieken im Orbit!"; speechTimer = 260; } // ============================================================================ // 5. RENDERING (DUAL-MODE: STANDARD & WCAG 2.1 AA HIGH CONTRAST) // ============================================================================ void drawBackground() { if (a11yMode) { background(0); } else { background(14, 19, 32); } noStroke(); for (int i = 0; i < NUM_STARS; i++) { if (a11yMode) { fill(200); } else { fill(170, 190, 220, 110); } ellipse(starX[i], starY[i], starSize[i], starSize[i]); } } void drawStationAndPig() { pushMatrix(); translate(stationX, stationY); // Docking / Refuel Perimeter Ring noFill(); if (a11yMode) { stroke(255, 255, 0); strokeWeight(2); } else { stroke(90, 200, 180, 90); strokeWeight(1.5); } ellipse(0, 0, (stationRadius + 24) * 2, (stationRadius + 24) * 2); // Outer Habitat Rings (grows visually with stationLevel) for (int l = 0; l < min(stationLevel, 4); l++) { float rRing = stationRadius - l * 7; if (a11yMode) { fill(20); stroke(255); strokeWeight(2.5); } else { fill(32, 48, 72, 190); stroke(110, 210, 195); strokeWeight(2); } ellipse(0, 0, rRing * 2, rRing * 2); } // Green Meadow Floor inside Dome noStroke(); if (a11yMode) { fill(0, 90, 40); } else { fill(54, 115, 72); } ellipse(0, 10, stationRadius * 1.35, stationRadius * 0.85); // Cute Guinea Pig ("Meerschweinchen") inside Habitat float bounce = sin(pigBob) * 2.2; pushMatrix(); translate(0, 6 + bounce); // Body if (a11yMode) { fill(255, 220, 0); stroke(0); strokeWeight(2); } else { fill(198, 134, 82); stroke(95, 58, 32); strokeWeight(1.5); } ellipse(0, 0, 34, 22); // White/Cream Patch noStroke(); fill(a11yMode ? 255 : 245, 238, 220); ellipse(-3, 0, 12, 18); // Ear fill(a11yMode ? 255 : 140, 88, 52); ellipse(8, -8, 7, 8); // Eye fill(0); ellipse(11, -3, 3.5, 3.5); if (!a11yMode) { fill(255); ellipse(11.8, -3.8, 1.2, 1.2); } // Nose fill(a11yMode ? 255 : 235, 160, 165); ellipse(16, 0, 4, 3); popMatrix(); // Speech Bubble if (speechTimer > 0) { float boxW = textWidth(pigSpeech) + 22; float boxY = -stationRadius - 26; if (a11yMode) { fill(0); stroke(255, 255, 0); strokeWeight(2); } else { fill(245, 248, 255, 235); stroke(100, 180, 170); strokeWeight(1.5); } rect(-boxW * 0.5, boxY - 14, boxW, 24, 6); fill(a11yMode ? color(255, 255, 0) : color(20, 35, 50)); noStroke(); textAlign(CENTER, CENTER); text(pigSpeech, 0, boxY - 2); } popMatrix(); } void drawItems() { for (int i = 0; i < NUM_ITEMS; i++) { if (!itemActive[i]) continue; pushMatrix(); translate(itemX[i], itemY[i]); // Distinct shapes + colors for accessibility if (itemType[i] == 0) { // Cucumber slice (Circle with inner ring) if (a11yMode) { fill(0, 255, 120); stroke(255); strokeWeight(2); } else { fill(82, 196, 104); stroke(38, 110, 52); strokeWeight(1.5); } ellipse(0, 0, 16, 16); noFill(); ellipse(0, 0, 8, 8); } else if (itemType[i] == 1) { // Quantum Pellet (Diamond / Square) if (a11yMode) { fill(0, 220, 255); stroke(255); strokeWeight(2); } else { fill(95, 185, 245); stroke(40, 100, 160); strokeWeight(1.5); } rectMode(CENTER); rotate(QUARTER_PI); rect(0, 0, 12, 12); } else { // Space Herb (Triangle) if (a11yMode) { fill(255, 180, 0); stroke(255); strokeWeight(2); } else { fill(235, 175, 75); stroke(135, 90, 25); strokeWeight(1.5); } triangle(0, -9, 8, 7, -8, 7); } popMatrix(); } } void drawAsteroids() { for (int i = 0; i < NUM_ASTEROIDS; i++) { pushMatrix(); translate(astX[i], astY[i]); rotate(astAngle[i]); if (a11yMode) { fill(35); stroke(255); strokeWeight(2.5); } else { fill(78, 84, 98); stroke(125, 134, 152); strokeWeight(1.8); } beginShape(); int vertices = 8; for (int v = 0; v < vertices; v++) { float a = map(v, 0, vertices, 0, TWO_PI); float rOffset = (v % 2 == 0) ? astR[i] : astR[i] * 0.82; vertex(cos(a) * rOffset, sin(a) * rOffset); } endShape(CLOSE); popMatrix(); } } void drawShip() { // Draw Tractor Beam cone if active if (tractorActive) { if (a11yMode) { noFill(); stroke(0, 255, 255); strokeWeight(2); } else { fill(90, 230, 220, 35); stroke(90, 230, 220, 130); strokeWeight(1.5); } ellipse(shipX, shipY, 270, 270); } pushMatrix(); translate(shipX, shipY); rotate(shipAngle); // Thruster Flame if (keyUp && fuel > 0) { noStroke(); fill(a11yMode ? color(255, 255, 0) : color(255, 165, 60)); triangle(-12, -5, -24 - random(6), 0, -12, 5); } // Probe Hull if (a11yMode) { fill(255); stroke(255, 255, 0); strokeWeight(2.5); } else { fill(225, 232, 242); stroke(80, 140, 200); strokeWeight(2); } triangle(16, 0, -12, -11, -12, 11); // Cockpit Canopy noStroke(); fill(a11yMode ? color(0, 180, 255) : color(75, 195, 215)); ellipse(2, 0, 10, 7); popMatrix(); } void drawHUD() { rectMode(CORNER); if (a11yMode) { fill(0); stroke(255); strokeWeight(2); } else { fill(18, 26, 42, 215); stroke(70, 110, 145); strokeWeight(1); } rect(12, 12, width - 24, 38, 6); fill(a11yMode ? 255 : 230); noStroke(); textAlign(LEFT, CENTER); String modeLabel = a11yMode ? "High Contrast [H]" : "Standard [H]"; String hudText = "DTIM-ZEC WHEEK-SONDE | Fracht: " + cargoCount + "/" + cargoCapacity + " | Geliefert: " + deliveredTotal + " | Kuppel-Lv: " + stationLevel + " | Treibstoff: " + int(fuel) + "%" + " | Ansicht: " + modeLabel; text(hudText, 24, 31); // Controls hint at bottom textAlign(CENTER, CENTER); fill(a11yMode ? 255 : 165, 185, 210); text("Steuerung: [W/A/S/D] oder Pfeile = Schub | [LEERTASTE] = Traktorstrahl | [H] = Sehhilfe-Modus | [R] = Sonde zurücksetzen", width * 0.5, height - 18); } // ============================================================================ // 6. INPUT HANDLING // ============================================================================ void keyPressed() { if (key == 'w' || key == 'W' || keyCode == UP) keyUp = true; if (key == 's' || key == 'S' || keyCode == DOWN) keyDown = true; if (key == 'a' || key == 'A' || keyCode == LEFT) keyLeft = true; if (key == 'd' || key == 'D' || keyCode == RIGHT) keyRight = true; if (key == ' ') tractorActive = true; if (key == 'h' || key == 'H') { a11yMode = !a11yMode; } if (key == 'r' || key == 'R') { resetShip(); } } void keyReleased() { if (key == 'w' || key == 'W' || keyCode == UP) keyUp = false; if (key == 's' || key == 'S' || keyCode == DOWN) keyDown = false; if (key == 'a' || key == 'A' || keyCode == LEFT) keyLeft = false; if (key == 'd' || key == 'D' || keyCode == RIGHT) keyRight = false; if (key == ' ') tractorActive = false; }