/* ========================================================== MIT License von Jan Bühring & Gimini Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. Impressum: Jan Buehring Adress Zusatz: Frida-Buecker-Haus Loeningstr. 25-26 28195 Bremen Deutschland Email: jan@jan-buehring.de ========================================================== */ 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; boolean autoShieldBought = false, 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", "Sammle Energie und baue die Basis. Behalte die Risiken im Blick!"); } void draw() { background(6, 8, 15); drawTLWSpaceBackground(); for (int i = 0; i < tokens.size(); i++) { tokens.get(i).display(); } 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 (int i = 0; i < tokens.size(); i++) { TLWToken t = tokens.get(i); 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 (int i = 0; i < tokens.size(); i++) { TLWToken t = tokens.get(i); if (ship1Target != null && 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; float targetY = mouseY; if (aiActive && ship1Target != null) { targetX = ship1Target.x; targetY = ship1Target.y; } boolean isMoving = false; if (aiActive && dist(shipX, shipY, targetX, targetY) > 10) isMoving = true; if (!aiActive && mousePressed && mouseY < height - 150) isMoving = true; 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() { int spawned = 0; for (int i = tokens.size() - 1; i >= 0; i--) { TLWToken t = tokens.get(i); 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); color pc = color(0, 255, 220); for(int k=0; k<5; k++) particles.add(new Particle(t.x, t.y, random(-3,3), random(-3,3), pc, 2)); tokens.remove(i); spawned++; if (!aiUnlocked) { manualTokensCollected++; if (manualTokensCollected >= 5) { aiUnlocked = true; triggerStory("KI BEREIT", "KI-Sammler online. Die Schiffs-KI hilft nun beim Sammeln."); } } } } for (int i = 0; i < spawned; i++) { tokens.add(new TLWToken(random(50, width-50), random(50, height-180))); } } void updateGaiaSystem() { if (autoIsruBought && autoIsruActive) { if (waterLevel < 50 && shipPoints >= 20.0) { shipPoints -= 20.0; waterLevel += 12.0; } if (greenLevel < 50 && shipPoints >= 30.0) { shipPoints -= 30.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; triggerStory("TOPOLOGISCHE BALANCE", "Sieg! Der Planet traegt sich von selbst."); } } void updateColonistsAndSupply() { if (isruBought && !colonistsArrived) { supplyTimer += 0.04; if (supplyTimer >= 100) { colonistsArrived = true; colonistCount = 10; supplyTimer = 0; triggerStory("KOLONISTEN", "Die Siedler sind gelandet! Versorgungsschiffe folgen."); } } 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; triggerStory("AUFSTAND", "Die Kolonisten hungern! KI sabotiert."); } 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; if (solarRisk > 100 && !solarWarning && !isSolarFlare) { solarWarning = true; warningTimer = 180; if (autoShieldBought && !shieldOn) shieldOn = true; } if (solarWarning) { warningTimer--; if (warningTimer <= 0) { solarWarning = false; isSolarFlare = true; flareTimer = 300; solarRisk = 0; } } 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; } } 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); color pc = color(0,255,220); for(int k=0; k<5; k++) particles.add(new Particle(p.x, p.y, random(-2,2), random(-2,2), pc, 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; if (greenLevel > 20) greenLevel -= 20; else greenLevel = 0; if (waterLevel > 20) waterLevel -= 20; else waterLevel = 0; color ec = color(255,100,50); for(int k=0; k<20; k++) particles.add(new Particle(meteorX, meteorY, random(-5,5), random(-5,5), ec, 2)); } } } void drawTLWSpaceBackground() { for (int i = 0; i < fieldNodes.size(); i++) { TLWFieldNode node = fieldNodes.get(i); float sx2 = shipX; float sy2 = shipY; if (hasSecondShip) { sx2 = ship2X; sy2 = ship2Y; } node.updateAndDisplay(shipX, shipY, sx2, sy2); } boolean flash = false; if (isSolarFlare) flash = true; if (solarWarning && frameCount % 10 < 5) flash = true; if (flash) { 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() { boolean showAlarm = false; if (solarWarning || meteorWarning) { if (frameCount % 20 < 10) showAlarm = true; } if (showAlarm) { pushStyle(); fill(255, 50, 50); textSize(24); textAlign(CENTER); text("NOTFALL ALARM!", 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); // Energie 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, 32); // KI if (aiUnlocked) { if (aiActive) fill(0, 255, 100); else if (inRebellion) fill(255, 50, 50); else fill(80); rect(180, 16, 100, 22, 4); fill(0); textSize(9); if (inRebellion) text("KI SABOTIERT", 190, 30); else if (aiActive) text("KI: AN", 190, 30); else text("KI: AUS", 190, 30); } else { fill(150); textSize(10); text("KI lernt (" + manualTokensCollected + "/5)", 180, 30); } // Kolonisten & Fraktal if (isruBought) { if (!colonistsArrived) { fill(255, 200, 0); textSize(11); text("KOLONISTEN ANKUNFT: " + int(supplyTimer) + "%", 300, 20); } else { if (inRebellion) fill(255, 50, 50); else fill(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) { if (shipPoints >= 500 && colonistCount >= 50) fill(0, 255, 150); else fill(80); rect(450, 16, 170, 22, 4); fill(0); textSize(9); text("FRAKTAL KAUFEN (500 SP)", 455, 30); } else { if (colonistCount >= 50) fill(0, 255, 150); else fill(255, 80, 80); rect(450, 16, 170, 22, 4); fill(0); textSize(9); if (colonistCount >= 50) text("FRAKTAL: AKTIV", 455, 30); else text("FRAKTAL: ZU WENIG CREW", 455, 30); } } } // Basis fill(200, 220, 255); textSize(11); text("BASIS:", 20, 58); if (coreBought) fill(0, 255, 100); else fill(80); rect(65, 45, 60, 20, 4); fill(0); textSize(10); if (coreBought) text("Kern", 70, 59); else text("Kern (50E)", 70, 59); boolean sEm = false; if (solarWarning || isSolarFlare) sEm = true; if (!shieldBought) fill(80); else if (shieldOn) fill(0, 200, 255); else fill(100); rect(130, 45, 95, 20, 4); if (shieldOn) fill(0); else if (sEm && shieldBought) fill(255, 100, 100); else fill(255); if (shieldBought) { if (shieldOn) text("Schild: AN", 135, 59); else if (sEm) text("Schild (30E!)", 135, 59); else text("Schild: AUS", 135, 59); } else text("Schild (70E)", 135, 59); boolean mEm = false; if (meteorWarning || isMeteor) mEm = true; if (!defenseBought) fill(80); else if (defenseOn) fill(0, 200, 255); else fill(100); rect(230, 45, 95, 20, 4); if (defenseOn) fill(0); else if (mEm && defenseBought) fill(255, 100, 100); else fill(255); if (defenseBought) { if (defenseOn) text("Abwehr: AN", 235, 59); else if (mEm) text("Abwehr (30E!)", 235, 59); else text("Abwehr: AUS", 235, 59); } else text("Abwehr (80E)", 235, 59); if (isruBought) fill(0, 255, 100); else fill(80); rect(330, 45, 70, 20, 4); fill(0); if (isruBought) text("ISRU: OK", 335, 59); else text("ISRU (90E)", 335, 59); if (isruBought) { if (autoShieldBought) fill(200, 100, 255); else fill(60); rect(420, 45, 130, 20, 4); fill(255); if (autoShieldBought) text("AUTO-SCHILD: OK", 425, 59); else text("Auto-Schild (200 SP)", 425, 59); if (autoDefenseBought) fill(200, 100, 255); else fill(60); rect(555, 45, 130, 20, 4); fill(255); if (autoDefenseBought) text("AUTO-ABWEHR: OK", 560, 59); else text("Auto-Abwehr (200 SP)", 560, 59); } // Prod 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); if (!autoIsruBought) fill(60); else if (autoIsruActive) fill(200, 100, 255); else fill(100); rect(420, 72, 130, 20, 4); fill(255); if (autoIsruBought) { if (autoIsruActive) text("AUTO-ISRU: AN (-SP)", 425, 86); else text("AUTO-ISRU: AUS", 425, 86); } else text("Auto-ISRU (150 SP)", 425, 86); if (greenLevel >= 10) { fill(180, 50, 50); rect(555, 72, 140, 20, 4); fill(255); text("Notverkauf -10% Flora", 560, 86); } } // Handel & Versorgung if (colonistsArrived) { fill(200, 220, 255); textSize(11); text("VERSORGUNG IN: " + int(supplyTimer) + "%", 20, 112); if (tradePolicy == 0) fill(0, 255, 150); else fill(255, 80, 80); rect(180, 98, 175, 20, 4); fill(0); textSize(9); if (tradePolicy == 0) text("LEGAL (Konsolen/Med)", 185, 112); else text("SCHWARZMARKT (Drogen)", 185, 112); if (tradePolicy == 1) { fill(255, 100, 200); text("DROGEN: " + int(drugSupply), 365, 112); } fill(200, 180, 50); rect(470, 98, 140, 20, 4); fill(0); text("EXPRESS KOLONIST (100)", 475, 112); fill(200, 180, 50); rect(620, 98, 140, 20, 4); fill(0); text("EXPRESS FRACHT (100)", 625, 112); } // Risiken Rechts (Immer sichtbar) textSize(10); if (solarRisk > 75) fill(255, 100, 100); else fill(200, 220, 255); text("SONNEN-GEFAHR: " + int(min(100, solarRisk)) + "%", 710, 40); if (meteorRisk > 75) fill(255, 100, 100); else fill(200, 220, 255); text("METEOR-GEFAHR: " + 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); 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; } if (aiUnlocked && !inRebellion && mouseX > 180 && mouseX < 280 && mouseY > 16 && mouseY < 38) { if (aiActive) aiActive = false; else aiActive = true; return; } 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; } } 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; } } else { if (shieldOn) shieldOn = false; else shieldOn = true; } } } 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; } } else { if (defenseOn) defenseOn = false; else defenseOn = true; } } } if (mouseX > 330 && mouseX < 400 && mouseY > 45 && mouseY < 65 && !isruBought && tlwEnergy >= 90) { tlwEnergy -= 90; isruBought = true; } 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) { if (autoIsruActive) autoIsruActive = false; else autoIsruActive = true; } } 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 < 695 && mouseY > 72 && mouseY < 92) { greenLevel -= 10.0; tlwEnergy = min(maxEnergy, tlwEnergy + 45.0); color pc = color(100, 255, 100); for(int k=0; k<15; k++) particles.add(new Particle(width/2, height-60, random(-3,3), random(-3,-1), pc, 2)); } } if (colonistsArrived) { // Trade Switch if (mouseX > 180 && mouseX < 355 && mouseY > 98 && mouseY < 118) { if (tradePolicy == 0) tradePolicy = 1; else tradePolicy = 0; } // Express Buttons if (mouseX > 470 && mouseX < 610 && mouseY > 98 && mouseY < 118 && shipPoints >= 100) { shipPoints -= 100; colonistCount += 5; } if (mouseX > 620 && mouseX < 760 && 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, y = baseY; float dShip1 = dist(x, y, sx, sy), 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() { if (x < 0) return true; if (x > width) return true; if (y < 0) return true; if (y > height) return true; return false; } } 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); float s = 6; if (type == 1) s = 4; ellipse(x, y, s, s); popStyle(); } boolean isDead() { if (alpha <= 0) return true; return false; } }