// ========================================================== // TLW-Modell: Notfall-Alarme, Auto-Upgrades & Express-Lieferungen // Website: jan-buehring.de | Hard Sci-Fi Simulation // ========================================================== float shipX, shipY, velocityX = 0, velocityY = 0; float tlwEnergy = 70.0, maxEnergy = 400.0; // KI & Automatisierung int manualTokensCollected = 0; boolean aiUnlocked = false, aiActive = false; TLWToken ship1Target = null, ship2Target = null; // Basis-Upgrades boolean coreBought = false; boolean shieldBought = false, shieldOn = false; boolean defenseBought = false, defenseOn = false; boolean isruBought = false; // Auto-Upgrades (über SP) boolean autoShieldBought = false; boolean autoDefenseBought = false; boolean autoIsruBought = false, autoIsruActive = false; // Gaia-System & Ressourcen float greenLevel = 0.0, waterLevel = 0.0; boolean balanceReached = false; // Kolonisten, Fraktal-Schiff & Soziologie boolean colonistsArrived = false; float colonistCount = 0.0, satisfaction = 80.0, shipPoints = 0.0; boolean inRebellion = false, hasSecondShip = false; float ship2X = 0, ship2Y = 0, ship2Vx = 0, ship2Vy = 0; // Versorgung & Handel float supplyTimer = 0.0, drugSupply = 0.0; int tradePolicy = 0; // 0 = Legal, 1 = Schwarzmarkt // Event-Risiken & Alarme float solarRisk = 0.0, meteorRisk = 0.0; boolean isSolarFlare = false, isMeteor = false; boolean solarWarning = false, meteorWarning = false; int warningTimer = 0, flareTimer = 0; float meteorX, meteorY, meteorSize = 60, meteorHP = 100; // Story-Steuerung String activePopupTitle = "", activePopupText = ""; boolean showPopup = false, pauseForWarning = false; ArrayList tokens; ArrayList particles; ArrayList fieldNodes; ArrayList projectiles; void setup() { size(900, 680); shipX = width / 2; shipY = (height - 150) / 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-180))); for (int x = 40; x < width; x += 70) { for (int y = 40; y < height - 160; y += 70) fieldNodes.add(new TLWFieldNode(x, y)); } triggerStory("TLW-ENDGAME", "Nutze Schiffspunkte (SP) taktisch! Schalte Auto-Schilde und Auto-Produktion frei oder fordere Express-Fracht an. ACHTUNG: Events haben nun einen kurzen Vor-Alarm. Schaltest du Schilde erst im Notfall ein, kostet das massiv extra Energie!"); } void draw() { background(6, 8, 15); drawTLWSpaceBackground(); if (!pauseForWarning && !balanceReached) { updateAITargets(); updateShipMovement(); updateSecondShip(); manageTokens(); updateGaiaSystem(); updateEvents(); updateColonistsAndSupply(); } updateParticles(); if (!balanceReached) { drawShip(); drawSecondShip(); } else { shipX = lerp(shipX, width/2 - 30, 0.05); shipY = lerp(shipY, height/2 - 50, 0.05); ship2X = lerp(ship2X, width/2 + 30, 0.05); ship2Y = lerp(ship2Y, height/2 - 50, 0.05); drawShip(); if (hasSecondShip) drawSecondShip(); } drawAlarms(); drawHUD(); drawStoryPopup(); } void updateAITargets() { ship1Target = null; ship2Target = null; if (aiActive && tokens.size() > 0) { float minDist = 9999; for (TLWToken t : tokens) { float d = dist(shipX, shipY, t.x, t.y); if (d < minDist) { minDist = d; ship1Target = t; } } } if (hasSecondShip && colonistCount >= 50 && tokens.size() > 0) { float minDist = 9999; for (TLWToken t : tokens) { if (t == ship1Target && tokens.size() > 1) continue; float d = dist(ship2X, ship2Y, t.x, t.y); if (d < minDist) { minDist = d; ship2Target = t; } } } } void updateShipMovement() { float targetX = mouseX, targetY = mouseY; if (aiActive && ship1Target != null) { targetX = ship1Target.x; targetY = ship1Target.y; } boolean isMoving = (aiActive && dist(shipX, shipY, targetX, targetY) > 10) || (!aiActive && mousePressed && mouseY < height - 150); if (isMoving && tlwEnergy > 0.2) { velocityX += (targetX - shipX) * 0.006; velocityY += (targetY - shipY) * 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 - 160); } void updateSecondShip() { if (hasSecondShip && colonistCount >= 50 && ship2Target != null) { ship2Vx += (ship2Target.x - ship2X) * 0.004; ship2Vy += (ship2Target.y - ship2Y) * 0.004; ship2Vx *= 0.92; ship2Vy *= 0.92; ship2X = constrain(ship2X + ship2Vx, 30, width - 30); ship2Y = constrain(ship2Y + ship2Vy, 30, height - 160); if (frameCount % 3 == 0) particles.add(new Particle(ship2X, ship2Y, -ship2Vx*0.5, -ship2Vy*0.5, color(0, 255, 150), 1)); } } void manageTokens() { for (int i = tokens.size() - 1; i >= 0; i--) { TLWToken t = tokens.get(i); t.display(); boolean collected = false; if (dist(shipX, shipY, t.x, t.y) < 25) collected = true; if (hasSecondShip && colonistCount >= 50 && dist(ship2X, ship2Y, t.x, t.y) < 25) collected = true; if (collected) { tlwEnergy = min(maxEnergy, tlwEnergy + 15.0); for(int k=0; k<5; k++) particles.add(new Particle(t.x, t.y, random(-3,3), random(-3,3), color(0, 255, 220), 2)); tokens.remove(i); tokens.add(new TLWToken(random(50, width-50), random(50, height-180))); if (!aiUnlocked) { manualTokensCollected++; if (manualTokensCollected >= 5) aiUnlocked = true; } } } } void updateGaiaSystem() { // KI Auto-ISRU Logic (Hier wurde autoIsruBought korrigiert) if (autoIsruBought && autoIsruActive) { if (waterLevel < 50 && tlwEnergy >= 15.0) { tlwEnergy -= 15.0; waterLevel += 12.0; } if (greenLevel < 50 && tlwEnergy >= 20.0) { tlwEnergy -= 20.0; greenLevel += 12.0; } } float energyDrain = 0.0; if (isruBought && greenLevel > 0) energyDrain += (greenLevel * 0.008); if (isruBought && waterLevel > 0) energyDrain += (waterLevel * 0.005); if (shieldOn) energyDrain += 0.15; if (defenseOn) energyDrain += 0.15; if (tlwEnergy >= energyDrain) { tlwEnergy -= energyDrain; } else { tlwEnergy = 0; shieldOn = false; defenseOn = false; if (greenLevel > 0) greenLevel -= 0.03; if (waterLevel > 0) waterLevel -= 0.03; } if (greenLevel >= 100 && waterLevel >= 100 && !balanceReached) { balanceReached = true; greenLevel = 100; waterLevel = 100; } } void updateColonistsAndSupply() { if (isruBought && !colonistsArrived) { supplyTimer += 0.04; if (supplyTimer >= 100) { colonistsArrived = true; colonistCount = 10; supplyTimer = 0; } } if (colonistsArrived) { supplyTimer += 0.05; if (supplyTimer >= 100) { supplyTimer = 0; colonistCount += 5; if (tradePolicy == 0) satisfaction = min(100, satisfaction + 15); else drugSupply += 100; } float demand = 0.015 + (colonistCount * 0.0005); boolean waterOk = false, greenOk = false; if (waterLevel >= demand) { waterLevel -= demand; waterOk = true; } else waterLevel = 0; if (greenLevel >= demand) { greenLevel -= demand; greenOk = true; } else greenLevel = 0; if (waterOk && greenOk) { if (tradePolicy == 1) { if (drugSupply > 0) { drugSupply -= (0.05 + colonistCount * 0.001); satisfaction = min(100, satisfaction + 0.08); } else satisfaction = max(0, satisfaction - 0.15); } else { satisfaction = min(100, satisfaction + 0.03); } if (satisfaction > 60) colonistCount += 0.03; } else { satisfaction = max(0, satisfaction - 0.1); if (satisfaction < 30 && colonistCount > 0) colonistCount -= 0.02; } if (!inRebellion) shipPoints += colonistCount * 0.01; if (satisfaction <= 15 && !inRebellion) { inRebellion = true; aiActive = false; } else if (satisfaction > 35 && inRebellion) { inRebellion = false; } if (inRebellion) { aiActive = false; if (frameCount % 10 == 0 && tlwEnergy > 0) tlwEnergy -= 1.0; } } } void updateEvents() { if (coreBought && !isSolarFlare && !solarWarning) solarRisk += 0.03; if (coreBought && !isMeteor && !meteorWarning) meteorRisk += 0.02; // Solar Flare Warning & Trigger if (solarRisk > 100 && !solarWarning && !isSolarFlare) { solarWarning = true; warningTimer = 180; // 3 Sekunden Alarm if (autoShieldBought && !shieldOn) shieldOn = true; } if (solarWarning) { warningTimer--; if (warningTimer <= 0) { solarWarning = false; isSolarFlare = true; flareTimer = 300; solarRisk = 0; } } // Meteor Warning & Trigger if (meteorRisk > 100 && !meteorWarning && !isMeteor) { meteorWarning = true; warningTimer = 180; if (autoDefenseBought && !defenseOn) defenseOn = true; } if (meteorWarning) { warningTimer--; if (warningTimer <= 0) { meteorWarning = false; isMeteor = true; meteorRisk = 0; meteorX = random(100, width-100); meteorY = -50; meteorHP = 100; } } // Active Events if (isSolarFlare) { flareTimer--; if (!shieldOn && frameCount % 5 == 0) { if (tlwEnergy > 0) tlwEnergy -= 2.0; else { if (greenLevel > 0) greenLevel -= 0.5; if (waterLevel > 0) waterLevel -= 0.5; } } if (flareTimer <= 0) isSolarFlare = false; } if (isMeteor) { meteorY += 0.8; meteorX += sin(frameCount*0.05)*0.5; if (defenseOn && frameCount % 12 == 0 && tlwEnergy >= 1.5) { tlwEnergy -= 1.5; projectiles.add(new Projectile(shipX, shipY, meteorX, meteorY)); } 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); } 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; if (meteorY > height - 130) { isMeteor = false; greenLevel = max(0, greenLevel - 20); waterLevel = max(0, waterLevel - 20); 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, hasSecondShip ? ship2X : shipX, hasSecondShip ? ship2Y : shipY); if (isSolarFlare || (solarWarning && frameCount%10 < 5)) { fill(255, 120, 0, 40); rect(0, 0, width, height - 150); } fill(120, 45, 25); noStroke(); rect(0, height - 150, width, 150); fill(190, 75, 40); rect(0, height - 158, width, 8); if (waterLevel > 0) { fill(50, 150, 255, map(waterLevel, 0, 100, 0, 120)); rect(0, height - 150, width, 150); } if (greenLevel > 0) { float alphaGreen = map(greenLevel, 0, 100, 0, 255); fill(30, 150, 50, alphaGreen); rect(0, height - 150, width, 150); fill(50, 200, 70, alphaGreen); rect(0, height - 158, width, 8); } if (shieldOn) { noFill(); stroke(0, 200, 255, 100); strokeWeight(3); arc(width/2, height - 150, width, 250, PI, TWO_PI); } } void drawAlarms() { if ((solarWarning || meteorWarning) && frameCount % 20 < 10) { pushStyle(); fill(255, 50, 50); textSize(24); textAlign(CENTER); text("⚠️ NOTFALL ALARM! SYSTEME AKTIVIEREN!", width/2, height/2 - 100); popStyle(); } } 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 drawSecondShip() { if (hasSecondShip) { pushStyle(); pushMatrix(); translate(ship2X, ship2Y); if (colonistCount >= 50) { rotate(frameCount * 0.08); stroke(0, 255, 150); } else { rotate(frameCount * 0.01); stroke(150, 50, 50); } noFill(); strokeWeight(1.5); for(int i = 0; i < 3; i++) { rotate(TWO_PI/3); triangle(0, -12, -10, 10, 10, 10); pushMatrix(); scale(0.5); rotate(-frameCount * 0.15); triangle(0, -12, -10, 10, 10, 10); popMatrix(); } popMatrix(); popStyle(); } } void drawHUD() { pushStyle(); fill(15, 20, 35, 240); stroke(60, 110, 190); strokeWeight(2); rect(10, 10, width - 20, 140, 8); // Row 1: Energie, KI, SP & Fraktal fill(40); noStroke(); rect(20, 20, 150, 16, 4); fill(255, 0, 200); rect(20, 20, map(tlwEnergy, 0, maxEnergy, 0, 150), 16, 4); fill(255); textSize(11); text("ENERGIE: " + int(tlwEnergy) + "/" + int(maxEnergy), 20, 16); if (aiUnlocked) { fill(aiActive ? color(0,255,100) : (inRebellion ? color(255,50,50) : color(80))); rect(180, 16, 100, 22, 4); fill(0); textSize(9); text(inRebellion ? "KI SABOTIERT" : (aiActive ? "KI: AN" : "KI: AUS"), 190, 30); } else { fill(150); textSize(10); text("KI lernt (" + manualTokensCollected + "/5)", 180, 30); } if (isruBought) { fill(inRebellion ? color(255,50,50) : color(0, 255, 150)); textSize(11); text("POP: " + int(colonistCount) + " | ZUF: " + int(satisfaction) + "%", 300, 20); fill(0, 200, 255); text("SP: " + int(shipPoints), 300, 34); if (!hasSecondShip) { fill((shipPoints >= 500 && colonistCount >= 50) ? color(0,255,150) : color(80)); rect(450, 16, 170, 22, 4); fill(0); textSize(10); text("FRAKTAL KAUFEN (500 SP)", 455, 30); } else { fill((colonistCount >= 50) ? color(0,255,150) : color(255,80,80)); rect(450, 16, 170, 22, 4); fill(0); textSize(10); text(colonistCount >= 50 ? "FRAKTAL: AKTIV" : "FRAKTAL: ZU WENIG CREW", 455, 30); } } // Row 2: Basis & Auto-Upgrades fill(200, 220, 255); textSize(11); text("BASIS:", 20, 58); fill(coreBought ? color(0,255,100) : color(80)); rect(65, 45, 60, 20, 4); fill(0); textSize(10); text(coreBought ? "Kern" : "Kern (50)", 70, 59); boolean sEm = (solarWarning || isSolarFlare); fill(shieldBought ? (shieldOn ? color(0,200,255) : color(100)) : color(80)); rect(130, 45, 95, 20, 4); fill(shieldOn ? 0 : (sEm && shieldBought ? color(255,100,100) : 255)); text(shieldBought ? (shieldOn ? "Schild: AN" : (sEm ? "Schild (30E!)" : "Schild: AUS")) : "Schild (70E)", 135, 59); boolean mEm = (meteorWarning || isMeteor); fill(defenseBought ? (defenseOn ? color(0,200,255) : color(100)) : color(80)); rect(230, 45, 95, 20, 4); fill(defenseOn ? 0 : (mEm && defenseBought ? color(255,100,100) : 255)); text(defenseBought ? (defenseOn ? "Abwehr: AN" : (mEm ? "Abwehr (30E!)" : "Abwehr: AUS")) : "Abwehr (80E)", 235, 59); fill(isruBought ? color(0,255,100) : color(80)); rect(330, 45, 70, 20, 4); fill(0); text(isruBought ? "ISRU" : "ISRU (90E)", 335, 59); // Auto-Upgrades (für SP) if (isruBought) { fill(autoShieldBought ? color(200,100,255) : color(60)); rect(420, 45, 130, 20, 4); fill(255); text(autoShieldBought ? "AUTO-SCHILD: OK" : "Auto-Schild (200 SP)", 425, 59); fill(autoDefenseBought ? color(200,100,255) : color(60)); rect(555, 45, 130, 20, 4); fill(255); text(autoDefenseBought ? "AUTO-ABWEHR: OK" : "Auto-Abwehr (200 SP)", 560, 59); } // Row 3: Produktion & ISRU if (isruBought) { fill(200, 220, 255); textSize(11); text("PROD:", 20, 85); fill(50, 150, 255); rect(65, 72, 85, 20, 4); fill(255); textSize(10); text("WASSER (15E)", 70, 86); fill(0); rect(155, 75, 40, 14); fill(50, 200, 255); rect(155, 75, map(waterLevel,0,100,0,40), 14); fill(255); text(int(waterLevel)+"%", 200, 86); fill(40, 180, 60); rect(240, 72, 85, 20, 4); fill(255); text("FLORA (20E)", 245, 86); fill(0); rect(330, 75, 40, 14); fill(0, 255, 100); rect(330, 75, map(greenLevel,0,100,0,40), 14); fill(255); text(int(greenLevel)+"%", 375, 86); // Auto-ISRU Upgrade fill(autoIsruBought ? (autoIsruActive ? color(200,100,255) : color(100)) : color(60)); rect(420, 72, 130, 20, 4); fill(255); text(autoIsruBought ? (autoIsruActive ? "AUTO-ISRU: AN" : "AUTO-ISRU: AUS") : "Auto-ISRU (150 SP)", 425, 86); if (greenLevel >= 10) { fill(180, 50, 50); rect(555, 72, 130, 20, 4); fill(255); text("Notverkauf -10% Flora", 560, 86); } } // Row 4: Handel & Express if (colonistsArrived) { fill(200, 220, 255); textSize(11); text("HANDEL:", 20, 112); fill(tradePolicy == 0 ? color(0,255,150) : color(255, 80, 80)); rect(65, 98, 175, 20, 4); fill(0); textSize(10); text(tradePolicy == 0 ? "LEGAL (Konsolen/Medizin)" : "SCHWARZMARKT (Drogen)", 70, 112); if (tradePolicy == 1) { fill(255, 100, 200); text("DROGEN: " + int(drugSupply), 245, 112); } // Express Buttons fill(color(200, 180, 50)); rect(420, 98, 130, 20, 4); fill(0); text("EXPRESS KOLONIST (100 SP)", 422, 112); fill(color(200, 180, 50)); rect(555, 98, 130, 20, 4); fill(0); text("EXPRESS FRACHT (100 SP)", 557, 112); } // Risiken Rechts textSize(10); if (solarRisk > 75) fill(255, 100, 100); else fill(200, 220, 255); text("☀️ SONNEN-RISIKO: " + int(min(100, solarRisk)) + "%", 710, 40); if (meteorRisk > 75) fill(255, 100, 100); else fill(200, 220, 255); text("⚠️ METEOR-RISIKO: " + int(min(100, meteorRisk)) + "%", 710, 55); 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 && !inRebellion && mouseX > 180 && mouseX < 280 && mouseY > 16 && mouseY < 38) { aiActive = !aiActive; return; } // Fraktal-Schiff if (isruBought && colonistsArrived && !hasSecondShip && mouseX > 450 && mouseX < 620 && mouseY > 16 && mouseY < 38) { if (shipPoints >= 500 && colonistCount >= 50) { shipPoints -= 500; hasSecondShip = true; ship2X = width/2; ship2Y = height/2; } } // Basis Aufbau & Toggles (inkl. Notfall-Strafe) if (mouseX > 65 && mouseX < 125 && mouseY > 45 && mouseY < 65 && !coreBought && tlwEnergy >= 50) { tlwEnergy -= 50; coreBought = true; } if (mouseX > 130 && mouseX < 225 && mouseY > 45 && mouseY < 65) { if (!shieldBought && tlwEnergy >= 70) { tlwEnergy -= 70; shieldBought = true; shieldOn = true; } else if (shieldBought) { if (!shieldOn && (solarWarning || isSolarFlare)) { if (tlwEnergy >= 30) { tlwEnergy -= 30; shieldOn = true; } // Notfall-Aufschlag } else { shieldOn = !shieldOn; } } } if (mouseX > 230 && mouseX < 325 && mouseY > 45 && mouseY < 65) { if (!defenseBought && tlwEnergy >= 80) { tlwEnergy -= 80; defenseBought = true; defenseOn = true; } else if (defenseBought) { if (!defenseOn && (meteorWarning || isMeteor)) { if (tlwEnergy >= 30) { tlwEnergy -= 30; defenseOn = true; } // Notfall-Aufschlag } else { defenseOn = !defenseOn; } } } if (mouseX > 330 && mouseX < 400 && mouseY > 45 && mouseY < 65 && !isruBought && tlwEnergy >= 90) { tlwEnergy -= 90; isruBought = true; } // Auto-Upgrades (SP) if (isruBought && mouseX > 420 && mouseX < 550 && mouseY > 45 && mouseY < 65 && !autoShieldBought && shipPoints >= 200) { shipPoints -= 200; autoShieldBought = true; } if (isruBought && mouseX > 555 && mouseX < 685 && mouseY > 45 && mouseY < 65 && !autoDefenseBought && shipPoints >= 200) { shipPoints -= 200; autoDefenseBought = true; } if (isruBought && mouseX > 420 && mouseX < 550 && mouseY > 72 && mouseY < 92) { if (!autoIsruBought && shipPoints >= 150) { shipPoints -= 150; autoIsruBought = true; autoIsruActive = true; } else if (autoIsruBought) { autoIsruActive = !autoIsruActive; } } // Manuelle Produktion if (isruBought && !balanceReached) { if (mouseX > 65 && mouseX < 150 && mouseY > 72 && mouseY < 92 && tlwEnergy >= 15.0) { tlwEnergy -= 15.0; waterLevel = min(100, waterLevel + 12.0); } if (mouseX > 240 && mouseX < 325 && mouseY > 72 && mouseY < 92 && tlwEnergy >= 20.0) { tlwEnergy -= 20.0; greenLevel = min(100, greenLevel + 12.0); } if (greenLevel >= 10 && mouseX > 555 && mouseX < 685 && mouseY > 72 && mouseY < 92) { greenLevel -= 10.0; tlwEnergy = min(maxEnergy, tlwEnergy + 45.0); 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)); } // Handel umschalten if (colonistsArrived && mouseX > 65 && mouseX < 240 && mouseY > 98 && mouseY < 118) tradePolicy = (tradePolicy == 0) ? 1 : 0; } // Express Lieferungen (SP) if (colonistsArrived) { if (mouseX > 420 && mouseX < 550 && mouseY > 98 && mouseY < 118 && shipPoints >= 100) { shipPoints -= 100; colonistCount += 5; } if (mouseX > 555 && mouseX < 685 && mouseY > 98 && mouseY < 118 && shipPoints >= 100) { shipPoints -= 100; if (tradePolicy == 0) satisfaction = min(100, satisfaction + 15); else drugSupply += 100; } } } 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 sx2, float sy2) { float x = baseX; float y = baseY; float dShip1 = dist(x, y, sx, sy); float dShip2 = dist(x, y, sx2, sy2); if (dShip1 < 140) { float f = (140 - dShip1) * 0.12; x += cos(atan2(y - sy, x - sx)) * f; y += sin(atan2(y - sy, x - sx)) * f; } if (hasSecondShip && colonistCount >= 50 && dShip2 < 100) { float f = (100 - dShip2) * 0.15; x += cos(atan2(y - sy2, x - sx2)) * f; y += sin(atan2(y - sy2, x - sx2)) * f; } stroke(40, 80, 150, 70); point(x, y); if (baseX < width - 70 && baseY < height - 170) { 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; } }