// ========================================================== // TLW-Modell: Mars-Kolonisations-Demo (Ausbalanciert & Fair) // Website: jan-buehring.de | Hard Sci-Fi Simulation // ========================================================== float shipX, shipY; float velocityX = 0, velocityY = 0; float tlwEnergy = 80.0; // Mehr Startenergie für einen guten Einstieg float maxEnergy = 200.0; // Upgrades & Automatisierung boolean hasIdleCharger = false; boolean coreActive = false; boolean shieldActive = false; boolean isruActive = false; boolean hasTLWMagnetShield = false; boolean hasTLWDefense = false; // Kolonisten-Autonomie (Mars-Bewohner helfen mit!) float colonistProgress = 0.0; // Story & Event-Steuerung (Logischer, fairer Ablauf) int gamePhase = 0; // 0: Aufbau, 1: Sonnensturm-Event, 2: Meteoriten-Abwehr, 3: Sieg float flareIntensity = 0.0; float meteorX, meteorY; float meteorSize = 65; float meteorHP = 100.0; float meteorMaxHP = 100.0; String activePopupTitle = ""; String activePopupText = ""; boolean showPopup = false; boolean pauseForWarning = false; ArrayList tokens; ArrayList projectiles; ArrayList particles; ArrayList fieldNodes; void setup() { size(900, 680); shipX = width / 2; shipY = (height - 120) / 2; tokens = new ArrayList(); projectiles = new ArrayList(); particles = new ArrayList(); fieldNodes = 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("WILLKOMMEN AUF DEM MARS", "Das TLW-Modell bildet das Fundament dieser Mission. Sammle Energie, aktiviere das Lager-Tool und baue die Basis in deinem eigenen Tempo auf!"); } void draw() { background(6, 8, 15); // 1. TLW-Raumfeld-Hintergrund drawTLWSpaceBackground(); // 2. Idle-Laden & Kolonisten-Hilfe if (hasIdleCharger && !pauseForWarning) { if (frameCount % 12 == 0 && tlwEnergy < maxEnergy) { tlwEnergy += 1.2; // Spürbar schnelleres Laden } } // Kolonisten arbeiten eigenständig an der Basis, wenn der Kern aktiv ist if (coreActive && !pauseForWarning) { colonistProgress += 0.05; if (colonistProgress >= 100.0 && gamePhase == 0) { triggerSolarFlareEvent(); } } // 3. Gameplay je nach Phase if (!pauseForWarning) { if (gamePhase == 0 || gamePhase == 3) { updateNormalGameplay(); } else if (gamePhase == 1) { updateSolarFlareGameplay(); } else if (gamePhase == 2) { updateDisasterGameplay(); } } // 4. UI & Partikel updateParticles(); drawHUD(); drawStoryPopup(); } void updateNormalGameplay() { updateShipMovement(); manageTokens(); drawShip(); } void updateSolarFlareGameplay() { shipX = lerp(shipX, constrain(mouseX, 30, width - 30), 0.2); shipY = lerp(shipY, constrain(mouseY, 30, height - 140), 0.2); flareIntensity = sin(frameCount * 0.05) * 80 + 120; // Wenn der Spieler den Schild baut, löst sich das Event fair und elegant if (hasTLWMagnetShield) { gamePhase = 2; // Weiter zu Phase 2 (Meteoriten-Test) triggerStory("SONNENSTURM ERFOLGREICH ABGEWENDET", "Die Mars-Bewohner und dein TLW-Magnetfeld haben den Sonnensturm perfekt neutralisiert! Nun kündigt sich ein letzter kleiner Asteroid an – rüste die Abwehr aus."); } drawShip(); } void updateDisasterGameplay() { shipX = lerp(shipX, constrain(mouseX, 30, width - 30), 0.2); shipY = lerp(shipY, constrain(mouseY, 30, height - 140), 0.2); meteorY += 0.4; // Sehr gemächliches Tempo zum Reagieren meteorX += sin(frameCount * 0.02) * 0.5; // Wenn automatische Abwehr da ist ODER der Spieler schießt if (hasTLWDefense && frameCount % 15 == 0 && tlwEnergy >= 1.0) { tlwEnergy -= 1.0; projectiles.add(new Projectile(shipX, shipY, meteorX, meteorY)); } // Meteorit zeichnen pushStyle(); fill(180, 60, 40); stroke(255, 120, 50); strokeWeight(2); ellipse(meteorX, meteorY, meteorSize, meteorSize); fill(40); noStroke(); rect(meteorX - 40, meteorY - 50, 80, 8, 3); fill(255, 50, 50); float hpW = map(meteorHP, 0, meteorMaxHP, 0, 80); rect(meteorX - 40, meteorY - 50, hpW, 8, 3); popStyle(); // 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 -= 20; // Höherer Schaden für schnellen Erfolg 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)); } if (meteorHP <= 0) { gamePhase = 3; // Sieg-Modus! triggerStory("MISSION VOLLENDET: MARS KOLONISIERT", "Großartig! Das TLW-Modell hat in der Praxis bestanden. Die Mars-Bewohner sind sicher, die Atmosphäre ist stabil. Du hast die Demo erfolgreich gemeistert!"); } } else if (p.isOffScreen()) { projectiles.remove(i); } } drawShip(); } void updateShipMovement() { float targetX = mouseX; float targetY = mouseY; float dx = targetX - shipX; float dy = targetY - shipY; if (mousePressed && mouseY < height - 120 && tlwEnergy > 0.2) { velocityX += dx * 0.005; velocityY += dy * 0.005; tlwEnergy -= 0.1; 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 += velocityX; shipY += velocityY; shipX = constrain(shipX, 30, width - 30); shipY = constrain(shipY, 30, height - 140); } void triggerSolarFlareEvent() { gamePhase = 1; pauseForWarning = true; triggerStory("☀️ WISSENSCHAFTLICHER HINWEIS: SONNENSTURM", "Die Mars-Bewohner melden erste solare Einstrahlungen. Dank ihrer Hilfe haben wir Zeit: Baue jetzt den TLW-Magnet-Schild, um den Sturm physikalisch umzulenken!"); } void drawTLWSpaceBackground() { for (TLWFieldNode node : fieldNodes) { node.updateAndDisplay(shipX, shipY, (gamePhase == 1) ? flareIntensity : 0); } if (gamePhase == 1) { pushStyle(); noStroke(); for(int i=0; i= 0; i--) { TLWToken t = tokens.get(i); t.display(); if (dist(shipX, shipY, t.x, t.y) < 25) { tlwEnergy = min(maxEnergy, tlwEnergy + 25.0); // Korrigierte Schleife ohne Typkonflikt: 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))); } } } 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); float angle = (gamePhase == 2) ? atan2(meteorY - shipY, meteorX - shipX) - HALF_PI : atan2(velocityY, velocityX) + HALF_PI; rotate(angle); 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(15, 15, width - 30, 95, 8); fill(40); noStroke(); rect(25, 45, 180, 16, 4); fill((gamePhase == 1) ? color(255, 120, 0) : color(255, 0, 200)); float energyWidth = map(tlwEnergy, 0, maxEnergy, 0, 180); rect(25, 45, energyWidth, 16, 4); fill(255); textSize(12); text("TLW-ENERGIE: " + int(tlwEnergy) + " / " + int(maxEnergy), 25, 35); if (gamePhase == 1) { fill(255, 150, 0); text("☀️ SONNENSTURM AKTIV: Baue den TLW-Magnet-Schild!", 215, 35); } else if (gamePhase == 2) { fill(255, 80, 80); text("⚠️ METEORIT IM ANFLUG: Nutze die TLW-Abwehr!", 215, 35); } else if (gamePhase == 3) { fill(0, 255, 120); text("🎉 MISSION ERFOLGREICH: Mars besiedelt!", 215, 35); } else if (hasIdleCharger) { fill(0, 255, 120); text("[IDLE LAGER-TOOL & BEWOHNER AKTIV]", 215, 35); } textSize(11); fill(200, 220, 255); text("UPGRADES & SCHUTZ:", 25, 85); fill(hasIdleCharger ? color(0,255,100) : color(80)); rect(155, 72, 90, 26, 4); fill(0); textSize(10); text(hasIdleCharger ? "Lager: AN" : "Lager (40E)", 161, 88); fill(coreActive ? color(0,255,100) : color(80)); rect(250, 72, 85, 26, 4); fill(0); text(coreActive ? "1. Kern: OK" : "1. Kern (50E)", 255, 88); fill(shieldActive ? color(0,255,100) : color(80)); rect(340, 72, 85, 26, 4); fill(0); text(shieldActive ? "2. Schild: OK" : "2. Schild (70E)", 345, 88); fill(hasTLWMagnetShield ? color(0,255,100) : color(80)); rect(430, 72, 95, 26, 4); fill(0); text(hasTLWMagnetShield ? "Magnet: OK" : "Magnet (80E)", 435, 88); fill(hasTLWDefense ? color(0,255,100) : color(80)); rect(535, 72, 95, 26, 4); fill(0); text(hasTLWDefense ? "Abwehr: AN" : "Abwehr (70E)", 540, 88); if (coreActive) { stroke(0,255,100); noFill(); ellipse(width/2 - 120, height - 60, 45, 45); } if (shieldActive) { stroke(100,200,255,180); noFill(); arc(width/2, height - 60, 200, 130, PI, TWO_PI); } if (hasTLWMagnetShield) { stroke(255,200,0,220); noFill(); ellipse(width/2, height - 60, 240, 150); } 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("📡 WISSENSCHAFTLICHE NOTIZ: " + 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; } if (gamePhase == 2 && !hasTLWDefense) { if (tlwEnergy >= 2.0) { tlwEnergy -= 2.0; projectiles.add(new Projectile(shipX, shipY, meteorX, meteorY)); } return; } // Faire, günstigere Upgrade-Preise if (mouseX > 155 && mouseX < 245 && mouseY > 72 && mouseY < 98) { if (!hasIdleCharger && tlwEnergy >= 40) { tlwEnergy -= 40; hasIdleCharger = true; triggerStory("LAGER AKTIVIERT", "Vakuum-Energie fließt automatisch in deinen Speicher."); } } if (mouseX > 250 && mouseX < 335 && mouseY > 72 && mouseY < 98) { if (!coreActive && tlwEnergy >= 50) { tlwEnergy -= 50; coreActive = true; triggerStory("PHASE 1: KERN", "TLW-Kern online. Die Mars-Bewohner unterstützen nun den Aufbau!"); } } if (mouseX > 340 && mouseX < 425 && mouseY > 72 && mouseY < 98) { if (!shieldActive && tlwEnergy >= 70) { tlwEnergy -= 70; shieldActive = true; triggerStory("PHASE 2: ATMOSPHÄRE", "Atmo-Schild aufgebaut."); } } if (mouseX > 430 && mouseX < 525 && mouseY > 72 && mouseY < 98) { if (!hasTLWMagnetShield && tlwEnergy >= 80) { tlwEnergy -= 80; hasTLWMagnetShield = true; triggerStory("MAGNETSCHILD", "Künstlicher planetarer Magnet-Schild errichtet!"); } } if (mouseX > 535 && mouseX < 630 && mouseY > 72 && mouseY < 98) { if (!hasTLWDefense && tlwEnergy >= 70) { tlwEnergy -= 70; hasTLWDefense = true; triggerStory("ABWEHR BEREIT", "Automatische Zielerfassung aktiv."); } } } 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 flare) { float x = baseX; float y = baseY; float dShip = dist(x, y, sx, sy); if (dShip < 140) { float angle = atan2(y - sy, x - sx); float force = (140 - dShip) * 0.12; x += cos(angle) * force; y += sin(angle) * force; } if (gamePhase == 1) { x += random(-flare * 0.03, flare * 0.03); y += random(-flare * 0.03, flare * 0.03); } stroke((gamePhase == 1) ? color(255, 140, 50, 100) : color(40, 80, 150, 70)); point(x, y); if (baseX < width - 70 && baseY < height - 160) { stroke((gamePhase == 1) ? color(255, 100, 0, 80) : color(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); float speed = 14.0; vx = cos(angle) * speed; vy = sin(angle) * speed; } 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; } }