// ========================================================== // TLW-Modell: Gaia-Balance, Risikomanagement & Notverkauf // Website: jan-buehring.de | Hard Sci-Fi Simulation // ========================================================== float shipX, shipY; float velocityX = 0, velocityY = 0; float tlwEnergy = 60.0; float maxEnergy = 250.0; // KI & Automatisierung int manualTokensCollected = 0; boolean aiUnlocked = false; boolean aiActive = false; // Basis-Upgrades (Gekauft vs. Aktiviert) boolean coreBought = false; boolean shieldBought = false; boolean shieldOn = false; boolean isruBought = false; boolean defenseBought = false; boolean defenseOn = false; // Gaia-System (Ökopflanzen & Topologische Balance) float greenLevel = 0.0; // 0 bis 100 boolean balanceReached = false; // Event-Risiken & Warnsystem float solarRisk = 0.0; float meteorRisk = 0.0; boolean isSolarFlare = false; int flareTimer = 0; boolean isMeteor = false; float meteorX, meteorY; float meteorSize = 60; float meteorHP = 100; // Story-Steuerung String activePopupTitle = ""; String activePopupText = ""; boolean showPopup = false; boolean pauseForWarning = false; boolean firstFlareSeen = false; boolean firstMeteorSeen = false; ArrayList tokens; ArrayList particles; ArrayList fieldNodes; ArrayList projectiles; void setup() { size(900, 680); shipX = width / 2; shipY = (height - 120) / 2; tokens = new ArrayList(); particles = new ArrayList(); fieldNodes = new ArrayList(); projectiles = new ArrayList(); for (int i = 0; i < 7; i++) { tokens.add(new TLWToken(random(50, width-50), random(50, height-170))); } for (int x = 40; x < width; x += 70) { for (int y = 40; y < height - 140; y += 70) { fieldNodes.add(new TLWFieldNode(x, y)); } } triggerStory("TLW-BASIS & GEFAHREN", "Sammle Energie und baue die Basis. ACHTUNG: Der Mars ist gefährlich! Schilde und Abwehrsysteme verbrauchen Energie, wenn sie AN sind. Behalte die Risiko-Anzeigen im Blick und schalte sie nur ein, wenn es kritisch wird!"); } void draw() { background(6, 8, 15); drawTLWSpaceBackground(); if (!pauseForWarning && !balanceReached) { updateShipMovement(); manageTokens(); updateGaiaSystem(); updateEvents(); } updateParticles(); if (!balanceReached) { drawShip(); } else { shipX = lerp(shipX, width/2, 0.05); shipY = lerp(shipY, height/2 - 50, 0.05); drawShip(); } drawHUD(); drawStoryPopup(); } void updateShipMovement() { float targetX = mouseX; float targetY = mouseY; if (aiActive && tokens.size() > 0) { float minDist = 9999; TLWToken bestToken = null; for (TLWToken t : tokens) { float d = dist(shipX, shipY, t.x, t.y); if (d < minDist) { minDist = d; bestToken = t; } } if (bestToken != null) { targetX = bestToken.x; targetY = bestToken.y; } } boolean isMoving = (aiActive && dist(shipX, shipY, targetX, targetY) > 10) || (!aiActive && mousePressed && mouseY < height - 120); if (isMoving && tlwEnergy > 0.2) { float dx = targetX - shipX; float dy = targetY - shipY; velocityX += dx * 0.006; velocityY += dy * 0.006; tlwEnergy -= 0.05; if (frameCount % 2 == 0) { particles.add(new Particle(shipX, shipY, -velocityX * 0.6 + random(-0.5, 0.5), -velocityY * 0.6 + random(-0.5, 0.5), color(0, 200, 255), 1)); } } velocityX *= 0.94; velocityY *= 0.94; shipX = constrain(shipX + velocityX, 30, width - 30); shipY = constrain(shipY + velocityY, 30, height - 140); } void manageTokens() { for (int i = tokens.size() - 1; i >= 0; i--) { TLWToken t = tokens.get(i); t.display(); if (dist(shipX, shipY, t.x, t.y) < 25) { tlwEnergy = min(maxEnergy, tlwEnergy + 15.0); for(int k=0; k<5; k++) { float angle = random(TWO_PI); float speed = random(1.5, 4.0); particles.add(new Particle(t.x, t.y, cos(angle)*speed, sin(angle)*speed, color(0, 255, 220), 2)); } tokens.remove(i); tokens.add(new TLWToken(random(50, width-50), random(50, height-170))); if (!aiUnlocked) { manualTokensCollected++; if (manualTokensCollected >= 5) { aiUnlocked = true; triggerStory("KI-AUTOPILOT VERFÜGBAR", "Die Schiffs-KI kann Vakuum-Energie nun autonom sammeln. Klicke auf 'KI-SAMMLER', um den Autopiloten zu aktivieren."); } } } } } void updateGaiaSystem() { // Laufende Energiekosten float energyDrain = 0.0; if (isruBought && greenLevel > 0) { energyDrain += (greenLevel * 0.012); } // Pflanzen-Erhaltung if (shieldOn) { energyDrain += 0.15; } // TLW-Schild kostet Energie if (defenseOn) { energyDrain += 0.15; } // TLW-Abwehr kostet Energie if (tlwEnergy >= energyDrain) { tlwEnergy -= energyDrain; } else { tlwEnergy = 0; // Wenn Energie 0 ist, schalten sich Sicherheitssysteme ab und Pflanzen sterben shieldOn = false; defenseOn = false; if (greenLevel > 0) greenLevel -= 0.05; } if (greenLevel >= 100 && !balanceReached) { balanceReached = true; greenLevel = 100; triggerStory("TOPOLOGISCHE BALANCE ERREICHT", "Sieg! Der Mars versorgt sich nun vollständig selbst. Die Natur floriert ohne künstliche Eingriffe."); } } void updateEvents() { // Risiken steigen langsam an if (coreBought && !isSolarFlare) solarRisk += 0.04; if (coreBought && !isMeteor) meteorRisk += 0.03; // Auslöser Sonnensturm if (solarRisk > 100) { isSolarFlare = true; solarRisk = 0; flareTimer = 300; // Dauer des Sturms if (!firstFlareSeen) { firstFlareSeen = true; triggerStory("☀️ SONNENSTURM TRIFFT EIN", "Ein magnetischer Sturm fegt über den Planeten! Hoffentlich hast du den TLW-Schild rechtzeitig auf 'AN' geschaltet!"); } } // Auslöser Meteor if (meteorRisk > 100 && !isMeteor) { isMeteor = true; meteorRisk = 0; meteorX = random(100, width-100); meteorY = -50; meteorHP = 100; if (!firstMeteorSeen) { firstMeteorSeen = true; triggerStory("⚠️ METEORIT IM ANFLUG", "Ein Asteroid stürzt herab! Hast du die automatische TLW-Abwehr auf 'AN' geschaltet?"); } } // Sonnensturm Logik if (isSolarFlare) { flareTimer--; if (!shieldOn && frameCount % 5 == 0) { // Bestrafung wenn Schild aus ist if (tlwEnergy > 0) tlwEnergy -= 2.0; else if (greenLevel > 0) greenLevel -= 0.5; } if (flareTimer <= 0) isSolarFlare = false; } // Meteor Logik if (isMeteor) { meteorY += 1.0; meteorX += sin(frameCount*0.05)*0.5; // Auto-Abwehr feuert, wenn AN und Energie vorhanden if (defenseOn && frameCount % 12 == 0 && tlwEnergy >= 1.5) { tlwEnergy -= 1.5; projectiles.add(new Projectile(shipX, shipY, meteorX, meteorY)); } // Projektile Kollision for (int i = projectiles.size() - 1; i >= 0; i--) { Projectile p = projectiles.get(i); p.update(); p.display(); if (dist(p.x, p.y, meteorX, meteorY) < meteorSize/2) { meteorHP -= 25; projectiles.remove(i); for(int k=0; k<5; k++) particles.add(new Particle(p.x, p.y, random(-2,2), random(-2,2), color(0,255,220), 2)); } else if (p.isOffScreen()) projectiles.remove(i); } // Meteorit Darstellung fill(180, 60, 40); stroke(255, 120, 50); strokeWeight(2); ellipse(meteorX, meteorY, meteorSize, meteorSize); fill(40); noStroke(); rect(meteorX - 40, meteorY - 45, 80, 6, 2); fill(255, 50, 50); rect(meteorX - 40, meteorY - 45, map(meteorHP, 0, 100, 0, 80), 6, 2); if (meteorHP <= 0) { isMeteor = false; } // Einschlag! if (meteorY > height - 120) { isMeteor = false; greenLevel = max(0, greenLevel - 25); // Pflanzen werden zerstört for(int k=0; k<20; k++) particles.add(new Particle(meteorX, meteorY, random(-5,5), random(-5,5), color(255,100,50), 2)); } } } void drawTLWSpaceBackground() { for (TLWFieldNode node : fieldNodes) { node.updateAndDisplay(shipX, shipY); } if (isSolarFlare) { fill(255, 120, 0, 40); rect(0, 0, width, height - 120); } fill(120, 45, 25); noStroke(); rect(0, height - 120, width, 120); fill(190, 75, 40); rect(0, height - 128, width, 8); if (greenLevel > 0) { float alphaGreen = map(greenLevel, 0, 100, 0, 255); fill(30, 150, 50, alphaGreen); rect(0, height - 120, width, 120); fill(50, 200, 70, alphaGreen); rect(0, height - 128, width, 8); } // Zeichne Schild-Aura wenn aktiv if (shieldOn) { noFill(); stroke(0, 200, 255, 100); strokeWeight(3); arc(width/2, height - 120, width, 250, PI, TWO_PI); } } void updateParticles() { for (int i = particles.size() - 1; i >= 0; i--) { Particle p = particles.get(i); p.update(); p.display(); if (p.isDead()) particles.remove(i); } } void drawShip() { pushStyle(); pushMatrix(); translate(shipX, shipY); rotate(atan2(velocityY, velocityX) + HALF_PI); fill(0, 200, 255); stroke(255); strokeWeight(1.5); triangle(0, -18, -12, 16, 12, 16); fill(255, 100, 255); ellipse(0, 2, 6, 6); popMatrix(); popStyle(); } void drawHUD() { pushStyle(); fill(15, 20, 35, 235); stroke(60, 110, 190); strokeWeight(2); rect(10, 10, width - 20, 110, 8); // Energiebalken fill(40); noStroke(); rect(20, 35, 180, 16, 4); fill(255, 0, 200); rect(20, 35, map(tlwEnergy, 0, maxEnergy, 0, 180), 16, 4); fill(255); textSize(12); text("TLW-ENERGIE: " + int(tlwEnergy), 20, 27); // KI-Autopilot if (aiUnlocked) { fill(aiActive ? color(0,255,100) : color(80)); rect(215, 25, 115, 24, 4); fill(0); textSize(10); text(aiActive ? "KI-SAMMLER: AN" : "KI-SAMMLER: AUS", 225, 41); } else { fill(150); textSize(10); text("KI lernt... (" + manualTokensCollected + "/5)", 215, 41); } // Risikowarnungen textSize(11); if (solarRisk > 75) fill(255, 100, 100); else fill(200, 220, 255); text("☀️ SONNENSTURM RISIKO: " + int(min(100, solarRisk)) + "%", 360, 32); if (meteorRisk > 75) fill(255, 100, 100); else fill(200, 220, 255); text("⚠️ METEORIT RISIKO: " + int(min(100, meteorRisk)) + "%", 360, 48); // Buttons Reihe 1: Basis-Aufbau & Toggles fill(200, 220, 255); textSize(11); text("BASIS & TAKTIK:", 20, 75); // 1. Kern fill(coreBought ? color(0,255,100) : color(80)); rect(125, 62, 85, 24, 4); fill(0); textSize(10); text(coreBought ? "1. Kern: OK" : "1. Kern (50E)", 132, 78); // 2. Schild (Kaufen oder AN/AUS) if (!shieldBought) { fill(80); rect(215, 62, 90, 24, 4); fill(0); text("2. Schild (70E)", 222, 78); } else { fill(shieldOn ? color(0,200,255) : color(100)); rect(215, 62, 90, 24, 4); fill(shieldOn ? 0 : 255); text(shieldOn ? "Schild: AN" : "Schild: AUS", 232, 78); } // 3. Abwehr (Kaufen oder AN/AUS) if (!defenseBought) { fill(80); rect(310, 62, 95, 24, 4); fill(0); text("3. Abwehr (80E)", 316, 78); } else { fill(defenseOn ? color(0,200,255) : color(100)); rect(310, 62, 95, 24, 4); fill(defenseOn ? 0 : 255); text(defenseOn ? "Abwehr: AN" : "Abwehr: AUS", 325, 78); } // 4. ISRU fill(isruBought ? color(0,255,100) : color(80)); rect(410, 62, 85, 24, 4); fill(0); text(isruBought ? "4. ISRU: OK" : "4. ISRU (90E)", 417, 78); // Buttons Reihe 2: GAIA Push & Notverkauf if (isruBought) { fill(40, 180, 60); rect(125, 90, 140, 24, 4); fill(255); text("GAIA PUSHEN (20E)", 140, 106); // Balken Grün fill(0); rect(275, 93, 100, 16); fill(0, 255, 100); rect(275, 93, greenLevel, 16); fill(255); text(int(greenLevel) + "%", 385, 105); // Flora-Notverkauf Button if (greenLevel >= 10) { fill(180, 50, 50); rect(435, 90, 175, 24, 4); fill(255); text("NOTFALL: -10% Flora -> +50E", 445, 106); } } popStyle(); } void drawStoryPopup() { if (showPopup) { pushStyle(); fill(10, 15, 30, 250); stroke(0, 200, 255); strokeWeight(2); rect(width/2 - 220, height/2 - 90, 440, 150, 10); fill(0, 255, 200); textSize(14); text("📡 " + activePopupTitle, width/2 - 200, height/2 - 60); fill(255); textSize(11); text(activePopupText, width/2 - 200, height/2 - 30, 400, 80); textSize(10); fill(150, 180, 220); text("[Klicken zum Fortfahren]", width/2 - 70, height/2 + 40); popStyle(); } } void mousePressed() { if (showPopup) { showPopup = false; pauseForWarning = false; return; } // KI umschalten if (aiUnlocked && mouseX > 215 && mouseX < 330 && mouseY > 25 && mouseY < 49) { aiActive = !aiActive; return; } // Kern kaufen if (mouseX > 125 && mouseX < 210 && mouseY > 62 && mouseY < 86 && !coreBought && tlwEnergy >= 50) { tlwEnergy -= 50; coreBought = true; triggerStory("TLW-KERN ONLINE", "Die Risiken für Sonnenstürme und Meteoriten steigen nun stetig. Sammle weiter!"); } // Schild kaufen oder schalten if (mouseX > 215 && mouseX < 305 && mouseY > 62 && mouseY < 86) { if (!shieldBought && tlwEnergy >= 70) { tlwEnergy -= 70; shieldBought = true; shieldOn = true; } else if (shieldBought) { shieldOn = !shieldOn; } } // Abwehr kaufen oder schalten if (mouseX > 310 && mouseX < 405 && mouseY > 62 && mouseY < 86) { if (!defenseBought && tlwEnergy >= 80) { tlwEnergy -= 80; defenseBought = true; defenseOn = true; } else if (defenseBought) { defenseOn = !defenseOn; } } // ISRU kaufen if (mouseX > 410 && mouseX < 495 && mouseY > 62 && mouseY < 86 && !isruBought && tlwEnergy >= 90) { tlwEnergy -= 90; isruBought = true; triggerStory("ISRU AKTIV", "Du kannst nun den Mars begrünen (Gaia pushen). Im Notfall kannst du Flora wieder in Energie umwandeln!"); } // Gaia pushen if (isruBought && !balanceReached && mouseX > 125 && mouseX < 265 && mouseY > 90 && mouseY < 114 && tlwEnergy >= 20.0) { tlwEnergy -= 20.0; greenLevel = min(100, greenLevel + 10.0); } // Flora-Notverkauf (Zweites Leben) if (isruBought && greenLevel >= 10 && mouseX > 435 && mouseX < 610 && mouseY > 90 && mouseY < 114) { greenLevel -= 10.0; tlwEnergy = min(maxEnergy, tlwEnergy + 50.0); // Visueller Effekt for(int k=0; k<15; k++) particles.add(new Particle(width/2, height-60, random(-3,3), random(-3,-1), color(100, 255, 100), 2)); } } void triggerStory(String title, String txt) { activePopupTitle = title; activePopupText = txt; showPopup = true; pauseForWarning = true; } class TLWFieldNode { float baseX, baseY; TLWFieldNode(float x, float y) { baseX = x; baseY = y; } void updateAndDisplay(float sx, float sy) { float x = baseX; float y = baseY; float dShip = dist(x, y, sx, sy); if (dShip < 140) { float force = (140 - dShip) * 0.12; x += cos(atan2(y - sy, x - sx)) * force; y += sin(atan2(y - sy, x - sx)) * force; } stroke(40, 80, 150, 70); point(x, y); if (baseX < width - 70 && baseY < height - 160) { stroke(35, 70, 130, 45); line(baseX, baseY, x, y); } } } class TLWToken { float x, y; TLWToken(float px, float py) { x = px; y = py; } void display() { pushStyle(); noStroke(); fill(0, 255, 220, 80); ellipse(x, y, 22, 22); fill(0, 255, 220, 220); ellipse(x, y, 12, 12); fill(255); ellipse(x, y, 5, 5); popStyle(); } } class Projectile { float x, y, vx, vy; Projectile(float startX, float startY, float targetX, float targetY) { x = startX; y = startY; float angle = atan2(targetY - startY, targetX - startX); vx = cos(angle) * 14.0; vy = sin(angle) * 14.0; } void update() { x += vx; y += vy; } void display() { pushStyle(); noStroke(); fill(255, 100, 255, 180); ellipse(x, y, 12, 22); fill(0, 255, 255); ellipse(x, y, 6, 14); fill(255); ellipse(x, y, 3, 8); popStyle(); } boolean isOffScreen() { return x < 0 || x > width || y < 0 || y > height; } } class Particle { float x, y, vx, vy, alpha; color col; int type; Particle(float px, float py, float dirX, float dirY, color c, int t) { x = px; y = py; vx = dirX; vy = dirY; alpha = 255; col = c; type = t; } void update() { x += vx; y += vy; if (type == 1) alpha -= 16; else { vx *= 0.92; vy *= 0.92; alpha -= 12; } } void display() { pushStyle(); noStroke(); fill(col, alpha); ellipse(x, y, type == 1 ? 4 : 6, type == 1 ? 4 : 6); popStyle(); } boolean isDead() { return alpha <= 0; } }