/* * 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; String statusMessage = "Willkommen Captain! Docke an einem Planeten an [L] oder fliege zu einem Nachbarsystem."; // Player Ship (DTIM-ZEC Light Freighter) float shipX, shipY; float shipVX, shipVY; float shipAngle = -HALF_PI; float fuel = 100.0; float maxFuel = 100.0; int credits = 250; // Ship Upgrade Levels (1..4) int lvlCargo = 1; // +10 Cargo per level int lvlEngine = 1; // +Thrust & Top Speed int lvlTank = 1; // +40 Max Fuel per level int lvlHull = 1; // Asteroid shield / visual hull plating // Cargo Hold (4 Goods) int NUM_GOODS = 4; String[] goodName = {"Raum-Gurken", "DTIM-Isotope", "Meerschweinchen-Heu", "Quanten-Chips"}; int[] cargo = {0, 0, 0, 0}; // Docked State boolean isDocked = true; int dockedPlanet = 0; // ============================================================================ // 2. PLANETS & DYNAMIC LOCAL MARKETS // ============================================================================ int NUM_PLANETS = 6; String[] planetName = { "Neu-Bremen (Agrar)", "ZEC-Raffinerie IV", "Wheek-Habitat Omega", "Axion-Werft", "Chlorophyll-Station", "Metrik-Außenposten" }; String[] planetSpec = { "Exportiert Gurken & Heu", "Exportiert DTIM-Isotope", "Kauft Gurken & Heu teuer", "Schiffsausbau & Chips", "Bio-Forschung & Agrar", "Hohe Nachfrage nach Technik" }; float[] planetX = {180, 560, 380, 170, 580, 390}; float[] planetY = {170, 150, 310, 470, 480, 120}; float[] planetR = {34, 30, 36, 32, 28, 26}; int[][] marketPrice = new int[NUM_PLANETS][NUM_GOODS]; // Gentle drifting asteroids (minor hazard, bounces softly) int NUM_ASTEROIDS = 7; 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]; // Background stars int NUM_STARS = 55; float[] starX = new float[NUM_STARS]; float[] starY = new float[NUM_STARS]; // Flight Controls boolean keyUp = false; boolean keyDown = false; boolean keyLeft = false; boolean keyRight = false; // ============================================================================ // 3. INITIALIZATION // ============================================================================ void setup() { size(1060, 640); smooth(); textFont(createFont("SansSerif", 13)); for (int i = 0; i < NUM_STARS; i++) { starX[i] = random(20, 740); starY[i] = random(55, height - 45); } initGame(); } void initGame() { credits = 250; lvlCargo = 1; lvlEngine = 1; lvlTank = 1; lvlHull = 1; maxFuel = 100.0; fuel = 100.0; for (int g = 0; g < NUM_GOODS; g++) { cargo[g] = 0; } dockedPlanet = 0; isDocked = true; shipX = planetX[0]; shipY = planetY[0]; shipVX = 0; shipVY = 0; shipAngle = -HALF_PI; for (int i = 0; i < NUM_ASTEROIDS; i++) { astX[i] = random(80, 680); astY[i] = random(90, 560); astVX[i] = random(-0.35, 0.35); astVY[i] = random(-0.35, 0.35); astR[i] = random(14, 24); } updateMarketPrices(); statusMessage = "Angedockt an " + planetName[0] + ". Kaufe günstige Waren und starte mit [L]!"; } void updateMarketPrices() { // Base prices: Gurken ~18, Isotope ~45, Heu ~14, Chips ~75 int[] base = {18, 45, 14, 75}; for (int p = 0; p < NUM_PLANETS; p++) { for (int g = 0; g < NUM_GOODS; g++) { float mult = 1.0 + random(-0.15, 0.15); // Regional supply & demand if (p == 0 && (g == 0 || g == 2)) mult = 0.65; // Neu-Bremen cheap food/hay if (p == 1 && g == 1) mult = 0.60; // ZEC-Raffinerie cheap isotopes if (p == 2 && (g == 0 || g == 2)) mult = 1.55; // Wheek-Habitat pays high for cucumbers & hay! if (p == 3 && g == 3) mult = 0.65; // Axion-Werft cheap chips if (p == 4 && g == 0) mult = 0.70; // Chlorophyll cheap cucumbers if (p == 5 && (g == 1 || g == 3)) mult = 1.45; // Metrik-Außenposten pays high for tech/isotopes marketPrice[p][g] = max(5, int(base[g] * mult)); } } } // ============================================================================ // 4. MAIN DRAW LOOP // ============================================================================ void draw() { drawBackground(); updateSpaceFlight(); drawPlanets(); drawAsteroids(); drawShip(); drawTopBar(); drawSidePanel(); drawBottomBar(); } // ============================================================================ // 5. FLIGHT KINEMATICS (ENDLESS SKY STYLE) // ============================================================================ void updateSpaceFlight() { // Asteroids always drift gently for (int i = 0; i < NUM_ASTEROIDS; i++) { astX[i] += astVX[i]; astY[i] += astVY[i]; if (astX[i] < 30) astX[i] = 730; if (astX[i] > 730) astX[i] = 30; if (astY[i] < 65) astY[i] = height - 50; if (astY[i] > height - 50) astY[i] = 65; } if (isDocked) { shipX = planetX[dockedPlanet]; shipY = planetY[dockedPlanet]; shipVX = 0; shipVY = 0; return; } // Rotation & Thrust scaled by Engine Level float turnRate = 0.045 + lvlEngine * 0.008; float thrust = 0.08 + lvlEngine * 0.025; float maxSpeed = 3.6 + lvlEngine * 0.7; if (keyLeft) shipAngle -= turnRate; if (keyRight) shipAngle += turnRate; if (keyUp && fuel > 0) { shipVX += cos(shipAngle) * thrust; shipVY += sin(shipAngle) * thrust; fuel = max(0, fuel - 0.045); } if (keyDown && fuel > 0) { // Retro-braking (Endless Sky style) shipVX *= 0.94; shipVY *= 0.94; fuel = max(0, fuel - 0.02); } // Gentle space drag for relaxed handling shipVX *= 0.992; shipVY *= 0.992; float spd = dist(0, 0, shipVX, shipVY); if (spd > maxSpeed) { shipVX = (shipVX / spd) * maxSpeed; shipVY = (shipVY / spd) * maxSpeed; } shipX += shipVX; shipY += shipVY; // Keep ship inside sector map bounds (25..735, 60..height-45) if (shipX < 25) { shipX = 25; shipVX *= -0.5; } if (shipX > 735) { shipX = 735; shipVX *= -0.5; } if (shipY < 60) { shipY = 60; shipVY *= -0.5; } if (shipY > height - 45) { shipY = height - 45; shipVY *= -0.5; } // Soft asteroid bump for (int i = 0; i < NUM_ASTEROIDS; i++) { float d = dist(shipX, shipY, astX[i], astY[i]); if (d < astR[i] + 12) { float push = atan2(shipY - astY[i], shipX - astX[i]); shipVX = cos(push) * 1.8; shipVY = sin(push) * 1.8; } } } int getNearbyPlanet() { for (int i = 0; i < NUM_PLANETS; i++) { if (dist(shipX, shipY, planetX[i], planetY[i]) <= planetR[i] + 22) { return i; } } return -1; } int getUsedCargo() { int sum = 0; for (int g = 0; g < NUM_GOODS; g++) sum += cargo[g]; return sum; } int getMaxCargo() { return 10 + (lvlCargo - 1) * 10; } // ============================================================================ // 6. RENDERING: SECTOR MAP, PLANETS & FREIGHTER // ============================================================================ void drawBackground() { background(a11yMode ? 0 : color(11, 16, 28)); noStroke(); for (int i = 0; i < NUM_STARS; i++) { fill(a11yMode ? 175 : color(160, 185, 220, 95)); ellipse(starX[i], starY[i], 2, 2); } } void drawPlanets() { int nearIdx = getNearbyPlanet(); for (int i = 0; i < NUM_PLANETS; i++) { float x = planetX[i]; float y = planetY[i]; float r = planetR[i]; // Docking Orbit Ring noFill(); if (i == nearIdx || (isDocked && i == dockedPlanet)) { stroke(a11yMode ? color(255, 255, 0) : color(105, 230, 200, 190)); strokeWeight(2); } else { stroke(a11yMode ? color(110) : color(65, 95, 130, 90)); strokeWeight(1); } ellipse(x, y, (r + 22) * 2, (r + 22) * 2); // Planet Sphere with distinct visual pattern per world if (a11yMode) { fill(25); stroke(255); strokeWeight(2.5); } else { if (i == 0 || i == 4) fill(62, 148, 105); // Agrar / Bio green-teal else if (i == 1) fill(185, 115, 65); // Refinery amber else if (i == 2) fill(95, 165, 215); // Wheek Habitat blue else fill(125, 115, 165); // Tech / Outpost violet-slate stroke(200, 225, 245); strokeWeight(1.8); } ellipse(x, y, r * 2, r * 2); // Ring or Surface Detail for distinct silhouette if (i == 2 || i == 3) { noFill(); stroke(a11yMode ? color(255, 255, 0) : color(180, 220, 240, 150)); ellipse(x, y, r * 2.7, r * 0.75); } // Planet Label textAlign(CENTER, TOP); fill(a11yMode ? 255 : 230); noStroke(); text(planetName[i], x, y + r + 8); } } void drawAsteroids() { for (int i = 0; i < NUM_ASTEROIDS; i++) { fill(a11yMode ? 40 : color(75, 82, 98)); stroke(a11yMode ? 220 : color(125, 135, 155)); strokeWeight(1.5); ellipse(astX[i], astY[i], astR[i] * 2, astR[i] * 1.7); } } void drawShip() { if (isDocked) return; pushMatrix(); translate(shipX, shipY); rotate(shipAngle); // Thruster Flame if (keyUp && fuel > 0) { noStroke(); fill(a11yMode ? color(255, 255, 0) : color(255, 165, 55)); triangle(-14, -5, -26 - random(6), 0, -14, 5); } // Freighter Hull (scales visually with Cargo & Hull upgrades) float w = 16 + lvlCargo * 1.5; float h = 10 + lvlHull * 1.2; if (a11yMode) { fill(255); stroke(255, 255, 0); strokeWeight(2.5); } else { fill(215, 225, 240); stroke(75, 155, 215); strokeWeight(2); } beginShape(); vertex(w, 0); vertex(4, -h); vertex(-14, -h * 0.85); vertex(-14, h * 0.85); vertex(4, h); endShape(CLOSE); // Cargo Pods visible on hull fill(a11yMode ? color(0, 220, 255) : color(85, 185, 215)); noStroke(); rectMode(CENTER); rect(-3, 0, 10, h * 1.1, 2); popMatrix(); } // ============================================================================ // 7. RENDERING: HUD, MARKET & SHIPYARD PANEL // ============================================================================ void drawTopBar() { rectMode(CORNER); fill(a11yMode ? 0 : color(18, 25, 42, 235)); stroke(a11yMode ? 255 : color(70, 105, 140)); strokeWeight(a11yMode ? 2 : 1); rect(10, 10, width - 20, 36, 6); fill(a11yMode ? 255 : 235); noStroke(); textAlign(LEFT, CENTER); String modeStr = a11yMode ? "High Contrast [H]" : "Standard [H]"; String info = "DTIM-ZEC: ENDLESS TRADER | Credits: " + credits + " Cr" + " | Frachtraum: " + getUsedCargo() + "/" + getMaxCargo() + " t" + " | Treibstoff: " + int(fuel) + "/" + int(maxFuel) + " | " + modeStr; text(info, 22, 28); } void drawSidePanel() { float px = 755; float py = 58; float pw = 295; float ph = height - 106; rectMode(CORNER); fill(a11yMode ? 10 : color(18, 26, 44, 240)); stroke(a11yMode ? 255 : color(75, 110, 150)); strokeWeight(a11yMode ? 2 : 1.5); rect(px, py, pw, ph, 8); float cx = px + 14; float cy = py + 22; textAlign(LEFT, CENTER); if (!isDocked) { int nearIdx = getNearbyPlanet(); fill(a11yMode ? color(255, 255, 0) : color(120, 220, 205)); text("IM FLUG (FREIER RAUM)", cx, cy); cy += 24; fill(a11yMode ? 255 : 215); text("Fliege zu einem Planeten-Orbit,", cx, cy); cy += 18; text("um Handel zu treiben oder zu tanken.", cx, cy); cy += 34; if (nearIdx != -1) { drawPrimaryButton(cx, cy, pw - 28, 36, "[L] ANDOCKEN: " + planetName[nearIdx]); } else { fill(a11yMode ? 200 : color(155, 175, 200)); text("Kein Planet in Dock-Reichweite.", cx, cy); } return; } // --- DOCKED VIEW: PLANET MARKET --- fill(a11yMode ? color(255, 255, 0) : color(120, 220, 205)); text("STATION: " + planetName[dockedPlanet], cx, cy); cy += 18; fill(a11yMode ? 220 : color(175, 205, 230)); text(planetSpec[dockedPlanet], cx, cy); cy += 26; // Goods Trade Rows for (int g = 0; g < NUM_GOODS; g++) { int price = marketPrice[dockedPlanet][g]; fill(a11yMode ? 255 : 230); text(goodName[g] + " (" + price + " Cr) [" + cargo[g] + "t]", cx, cy); cy += 20; drawSmallButton(cx, cy, 130, 24, "[" + (g + 1) + "] Kaufen"); drawSmallButton(cx + 137, cy, 130, 24, "[Shift+" + (g + 1) + "] Verkaufen"); cy += 32; } // Refuel Button int fuelNeeded = int(maxFuel - fuel); int refuelCost = max(1, fuelNeeded / 5); drawSmallButton(cx, cy, pw - 28, 26, "[T] Volltanken (" + (fuelNeeded > 0 ? refuelCost + " Cr" : "Voll") + ")"); cy += 36; // Divider stroke(a11yMode ? 255 : color(70, 100, 135)); line(cx, cy, px + pw - 14, cy); cy += 16; // --- SHIPYARD UPGRADES --- fill(a11yMode ? color(255, 255, 0) : color(120, 220, 205)); text("FRACHTER-WERFT (AUSBAU)", cx, cy); cy += 22; drawSmallButton(cx, cy, pw - 28, 25, "[U] Frachtraum Lv." + lvlCargo + " -> +10t (" + (lvlCargo * 90) + " Cr)"); cy += 30; drawSmallButton(cx, cy, pw - 28, 25, "[I] Triebwerk Lv." + lvlEngine + " -> Tempo (" + (lvlEngine * 100) + " Cr)"); cy += 30; drawSmallButton(cx, cy, pw - 28, 25, "[O] Treibstofftank Lv." + lvlTank + " -> +40 (" + (lvlTank * 80) + " Cr)"); cy += 38; // Launch Button drawPrimaryButton(cx, cy, pw - 28, 36, "[L] ABLEGEN & STARTEN"); } void drawSmallButton(float x, float y, float w, float h, String label) { if (a11yMode) { fill(0); stroke(255); strokeWeight(1.5); } else { fill(32, 46, 74); stroke(95, 145, 195); strokeWeight(1); } rect(x, y, w, h, 4); fill(a11yMode ? 255 : 235); noStroke(); textAlign(CENTER, CENTER); text(label, x + w * 0.5, y + h * 0.5); textAlign(LEFT, CENTER); } void drawPrimaryButton(float x, float y, float w, float h, String label) { if (a11yMode) { fill(255, 255, 0); stroke(255); strokeWeight(2); } else { fill(48, 135, 120); stroke(130, 240, 215); strokeWeight(1.5); } rect(x, y, w, h, 6); fill(a11yMode ? 0 : 255); noStroke(); textAlign(CENTER, CENTER); text(label, x + w * 0.5, y + h * 0.5); textAlign(LEFT, CENTER); } void drawBottomBar() { rectMode(CORNER); fill(a11yMode ? 0 : color(18, 25, 42, 235)); stroke(a11yMode ? 255 : color(70, 105, 140)); strokeWeight(a11yMode ? 2 : 1); rect(10, height - 38, width - 20, 28, 5); fill(a11yMode ? color(255, 255, 0) : color(195, 225, 245)); noStroke(); textAlign(LEFT, CENTER); text("Log: " + statusMessage + " | [W/A/S/D] Flug [L] Landen/Starten [H] Sehhilfe [R] Neustart", 22, height - 24); } // ============================================================================ // 8. TRADING, UPGRADES & INPUT HANDLING // ============================================================================ void buyGood(int g) { if (!isDocked) return; int price = marketPrice[dockedPlanet][g]; if (getUsedCargo() >= getMaxCargo()) { statusMessage = "Frachtraum voll! Baue ihn in der Werft aus oder verkaufe Waren."; return; } if (credits >= price) { credits -= price; cargo[g]++; statusMessage = "1t " + goodName[g] + " für " + price + " Cr gekauft."; } else { statusMessage = "Nicht genug Credits für " + goodName[g] + "."; } } void sellGood(int g) { if (!isDocked) return; if (cargo[g] > 0) { int price = marketPrice[dockedPlanet][g]; cargo[g]--; credits += price; statusMessage = "1t " + goodName[g] + " für " + price + " Cr verkauft!"; } else { statusMessage = "Keine " + goodName[g] + " an Bord."; } } void refuelShip() { if (!isDocked) return; int needed = int(maxFuel - fuel); if (needed <= 0) { statusMessage = "Tanks sind bereits voll."; return; } int cost = max(1, needed / 5); if (credits >= cost) { credits -= cost; fuel = maxFuel; statusMessage = "Frachter vollgetankt (-" + cost + " Cr)."; } else { statusMessage = "Nicht genug Credits zum Tanken."; } } void upgradeShip(int type) { if (!isDocked) return; if (type == 1 && lvlCargo < 4) { int cost = lvlCargo * 90; if (credits >= cost) { credits -= cost; lvlCargo++; statusMessage = "Frachtraum auf Stufe " + lvlCargo + " erweitert (" + getMaxCargo() + "t)!"; } else statusMessage = "Benötigt " + cost + " Cr."; } else if (type == 2 && lvlEngine < 4) { int cost = lvlEngine * 100; if (credits >= cost) { credits -= cost; lvlEngine++; statusMessage = "DTIM-Triebwerke auf Stufe " + lvlEngine + " aufgerüstet!"; } else statusMessage = "Benötigt " + cost + " Cr."; } else if (type == 3 && lvlTank < 4) { int cost = lvlTank * 80; if (credits >= cost) { credits -= cost; lvlTank++; maxFuel += 40.0; fuel = maxFuel; statusMessage = "Treibstofftank auf Stufe " + lvlTank + " vergrößert!"; } else statusMessage = "Benötigt " + cost + " Cr."; } else { statusMessage = "Maximale Ausbaustufe erreicht."; } } void toggleDock() { if (isDocked) { isDocked = false; shipY -= planetR[dockedPlanet] + 18; shipVY = -0.8; statusMessage = "Abgelegt von " + planetName[dockedPlanet] + ". Gute Reise!"; } else { int nearIdx = getNearbyPlanet(); if (nearIdx != -1) { isDocked = true; dockedPlanet = nearIdx; shipVX = 0; shipVY = 0; updateMarketPrices(); statusMessage = "Angedockt an " + planetName[dockedPlanet] + ". Marktpreise aktualisiert."; } else { statusMessage = "Kein Planet in Reichweite zum Landen."; } } } void mousePressed() { float cx = 769; float pw = 267; if (mouseX < cx || mouseX > cx + pw) return; if (!isDocked) { if (mouseY >= 152 && mouseY <= 188) toggleDock(); return; } // Buy / Sell Clicks float cy = 124; for (int g = 0; g < NUM_GOODS; g++) { if (mouseY >= cy && mouseY <= cy + 24) { if (mouseX <= cx + 130) buyGood(g); else sellGood(g); return; } cy += 52; } // Refuel if (mouseY >= 332 && mouseY <= 358) { refuelShip(); return; } // Shipyard Upgrades if (mouseY >= 406 && mouseY <= 431) { upgradeShip(1); return; } if (mouseY >= 436 && mouseY <= 461) { upgradeShip(2); return; } if (mouseY >= 466 && mouseY <= 491) { upgradeShip(3); return; } // Launch if (mouseY >= 504 && mouseY <= 540) { toggleDock(); return; } } 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 == '1') buyGood(0); if (key == '2') buyGood(1); if (key == '3') buyGood(2); if (key == '4') buyGood(3); if (key == '!') sellGood(0); if (key == '"') sellGood(1); if (key == '§') sellGood(2); if (key == '$') sellGood(3); if (key == 't' || key == 'T') refuelShip(); if (key == 'u' || key == 'U') upgradeShip(1); if (key == 'i' || key == 'I') upgradeShip(2); if (key == 'o' || key == 'O') upgradeShip(3); if (key == 'l' || key == 'L') toggleDock(); if (key == 'h' || key == 'H') a11yMode = !a11yMode; if (key == 'r' || key == 'R') initGame(); } 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; }