// ========================================================== // TLW-Modell: Soziologie, Schmuggel & Fraktal-Koordination // Website: jan-buehring.de | Hard Sci-Fi Simulation // ========================================================== float shipX, shipY; float velocityX = 0, velocityY = 0; float tlwEnergy = 70.0; float maxEnergy = 400.0; // KI & Automatisierung int manualTokensCollected = 0; boolean aiUnlocked = false; boolean aiActive = false; TLWToken ship1Target = null; TLWToken ship2Target = null; // Basis-Upgrades boolean coreBought = false; boolean shieldBought = false, shieldOn = false; boolean defenseBought = false, defenseOn = false; boolean isruBought = false; // Gaia-System & Ressourcen float greenLevel = 0.0; float waterLevel = 0.0; boolean balanceReached = false; // Kolonisten, Fraktal-Schiff & Soziologie boolean colonistsArrived = false; float colonistCount = 0.0; float satisfaction = 80.0; boolean inRebellion = false; float shipPoints = 0.0; boolean hasSecondShip = false; float ship2X = 0, ship2Y = 0; float ship2Vx = 0, ship2Vy = 0; // Versorgung, Handel & Schmuggel float supplyTimer = 0.0; int tradePolicy = 0; // 0 = Legal, 1 = Schwarzmarkt float drugSupply = 0.0; // Event-Risiken float solarRisk = 0.0, meteorRisk = 0.0; boolean isSolarFlare = false, isMeteor = false; int flareTimer = 0; float meteorX, meteorY, meteorSize = 60, meteorHP = 100; // Story-Steuerung String activePopupTitle = "", activePopupText = ""; boolean showPopup = false, pauseForWarning = false; boolean firstFlareSeen = false, firstMeteorSeen = false; ArrayList tokens; ArrayList particles; ArrayList fieldNodes; ArrayList projectiles; void setup() { size(900, 680); shipX = width / 2; shipY = (height - 140) / 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 - 150; y += 70) fieldNodes.add(new TLWFieldNode(x, y)); } triggerStory("TLW-KOLONIE & SCHMUGGEL", "Die KI-Schiffe koordinieren sich nun beim Sammeln. Neu: Versorgungsschiffe bringen regelmäßig Kolonisten und Güter. Du kannst im HUD entscheiden, ob der Warentransport LEGAL oder über den SCHWARZMARKT (Drogen) ablaufen soll. Hohes Risiko, hohe Belohnung!"); } void draw() { background(6, 8, 15); drawTLWSpaceBackground(); if (!pauseForWarning && !balanceReached) { updateAITargets(); // Koordination der Schiffe 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(); } drawHUD(); drawStoryPopup(); } void updateAITargets() { ship1Target = null; ship2Target = null; // Zielsuche Schiff 1 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; } } } // Zielsuche Schiff 2 (Fraktal) - ignoriert das Ziel von Schiff 1! if (hasSecondShip && colonistCount >= 50 && tokens.size() > 0) { float minDist = 9999; for (TLWToken t : tokens) { if (t == ship1Target && tokens.size() > 1) continue; // Absprache: anderes Ziel wählen 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 - 140); 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 - 150); } 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 - 150); 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; triggerStory("KI BEREIT", "KI-Sammler online."); } } } } } void updateGaiaSystem() { 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 ERREICHT", "Sieg! Der Planet trägt sich von selbst, die Siedler sind sicher und das Ökosystem floriert."); } } void updateColonistsAndSupply() { if (isruBought && !colonistsArrived) { supplyTimer += 0.04; if (supplyTimer >= 100) { colonistsArrived = true; colonistCount = 10; supplyTimer = 0; triggerStory("KOLONISTEN GELANDET", "Die Siedler sind da! Von nun an kommen regelmäßig Versorgungsschiffe. Wähle deine Handelspolitik mit Bedacht aus."); } } if (colonistsArrived) { // 1. Versorgungsschiffe Timer supplyTimer += 0.05; if (supplyTimer >= 100) { supplyTimer = 0; colonistCount += 5; // Neue Siedler if (tradePolicy == 0) { satisfaction = min(100, satisfaction + 15); triggerStory("VERSORGUNG: LEGAL", "Ein Transporter hat neue Kolonisten, Spielekonsolen und Medizin gebracht. Die Moral steigt."); } else { drugSupply += 100; triggerStory("VERSORGUNG: SCHWARZMARKT", "Schmuggler sind gelandet! Der Drogenvorrat ist gefüllt. Die Bevölkerung feiert, aber wehe der Nachschub reißt ab..."); } } // 2. Verbrauch & Soziologie 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) { // Schwarzmarkt-Konsum if (drugSupply > 0) { drugSupply -= (0.05 + colonistCount * 0.001); satisfaction = min(100, satisfaction + 0.08); // Starker Boost durch Konsum } else { satisfaction = max(0, satisfaction - 0.15); // Harter Entzug! } } else { // Legaler Konsum satisfaction = min(100, satisfaction + 0.03); // Normales Wachstum } if (satisfaction > 60) colonistCount += 0.03; } else { satisfaction = max(0, satisfaction - 0.1); // Mangel an Wasser/Luft if (satisfaction < 30 && colonistCount > 0) colonistCount -= 0.02; } if (!inRebellion) shipPoints += colonistCount * 0.01; // 3. Aufstand if (satisfaction <= 15 && !inRebellion) { inRebellion = true; aiActive = false; triggerStory("⚠️ AUFSTAND!", "Die Kolonisten hungern oder leiden unter schwerem Entzug! KI sabotiert. SP-Produktion gestoppt."); } 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) solarRisk += 0.03; if (coreBought && !isMeteor) meteorRisk += 0.02; if (solarRisk > 100) { isSolarFlare = true; solarRisk = 0; flareTimer = 300; if (!firstFlareSeen) { firstFlareSeen = true; triggerStory("☀️ SONNENSTURM", "Aktiviere den TLW-Schild!"); } } if (meteorRisk > 100 && !isMeteor) { isMeteor = true; meteorRisk = 0; meteorX = random(100, width-100); meteorY = -50; meteorHP = 100; if (!firstMeteorSeen) { firstMeteorSeen = true; triggerStory("⚠️ METEORIT", "Aktiviere die Abwehr!"); } } 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) { fill(255, 120, 0, 40); rect(0, 0, width, height - 130); } fill(120, 45, 25); noStroke(); rect(0, height - 130, width, 130); fill(190, 75, 40); rect(0, height - 138, width, 8); if (waterLevel > 0) { fill(50, 150, 255, map(waterLevel, 0, 100, 0, 120)); rect(0, height - 130, width, 130); } if (greenLevel > 0) { float alphaGreen = map(greenLevel, 0, 100, 0, 255); fill(30, 150, 50, alphaGreen); rect(0, height - 130, width, 130); fill(50, 200, 70, alphaGreen); rect(0, height - 138, width, 8); } if (shieldOn) { noFill(); stroke(0, 200, 255, 100); strokeWeight(3); arc(width/2, height - 130, 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 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, 235); stroke(60, 110, 190); strokeWeight(2); rect(10, 10, width - 20, 130, 8); // Energie & KI fill(40); noStroke(); rect(20, 25, 180, 16, 4); fill(255, 0, 200); rect(20, 25, map(tlwEnergy, 0, maxEnergy, 0, 180), 16, 4); fill(255); textSize(12); text("ENERGIE: " + int(tlwEnergy) + " / " + int(maxEnergy), 20, 18); if (aiUnlocked) { fill(aiActive ? color(0,255,100) : (inRebellion ? color(255,50,50) : color(80))); rect(215, 15, 115, 24, 4); fill(0); textSize(10); text(inRebellion ? "KI: SABOTIERT!" : (aiActive ? "KI-SAMMLER: AN" : "KI-SAMMLER: AUS"), 225, 31); } else { fill(150); textSize(10); text("KI lernt... (" + manualTokensCollected + "/5)", 215, 31); } // Kolonisten, SP & Fraktal if (isruBought) { if (!colonistsArrived) { fill(255, 200, 0); textSize(11); text("KOLONISTEN ANKUNFT: " + int(supplyTimer) + "%", 360, 22); } else { fill(inRebellion ? color(255,50,50) : color(0, 255, 150)); textSize(11); text("POPULATION: " + int(colonistCount) + " | ZUFRIEDENHEIT: " + int(satisfaction) + "% " + (inRebellion ? "[AUFSTAND]" : ""), 360, 18); fill(0, 200, 255); text("SCHIFFSPUNKTE (SP): " + int(shipPoints), 360, 32); if (!hasSecondShip) { fill((shipPoints >= 500 && colonistCount >= 50) ? color(0,255,150) : color(80)); rect(650, 15, 220, 22, 4); fill(0); textSize(10); text("2. SCHIFF KAUFEN (500 SP, 50 Pop)", 660, 29); } else { fill((colonistCount >= 50) ? color(0,255,150) : color(255,80,80)); rect(650, 15, 220, 22, 4); fill(0); textSize(10); text((colonistCount >= 50) ? "2. SCHIFF: AKTIV" : "2. SCHIFF: ZU WENIG CREW (Min 50)", 660, 29); } } } // Basis fill(200, 220, 255); textSize(11); text("BASIS:", 20, 60); fill(coreBought ? color(0,255,100) : color(80)); rect(70, 48, 80, 22, 4); fill(0); textSize(10); text(coreBought ? "Kern: OK" : "Kern (50)", 78, 62); if (!shieldBought) { fill(80); rect(160, 48, 80, 22, 4); fill(0); text("Schild (70)", 168, 62); } else { fill(shieldOn ? color(0,200,255) : color(100)); rect(160, 48, 80, 22, 4); fill(shieldOn ? 0 : 255); text(shieldOn ? "Schild: AN" : "Schild: AUS", 170, 62); } if (!defenseBought) { fill(80); rect(250, 48, 80, 22, 4); fill(0); text("Abwehr (80)", 258, 62); } else { fill(defenseOn ? color(0,200,255) : color(100)); rect(250, 48, 80, 22, 4); fill(defenseOn ? 0 : 255); text(defenseOn ? "Abwehr: AN" : "Abwehr: AUS", 258, 62); } fill(isruBought ? color(0,255,100) : color(80)); rect(340, 48, 80, 22, 4); fill(0); text(isruBought ? "ISRU: OK" : "ISRU (90)", 348, 62); // Risikowarnungen (Nach rechts geschoben) textSize(10); if (solarRisk > 75) fill(255, 100, 100); else fill(200, 220, 255); text("☀️ SONNEN-RISIKO: " + int(min(100, solarRisk)) + "%", 440, 55); if (meteorRisk > 75) fill(255, 100, 100); else fill(200, 220, 255); text("⚠️ METEOR-RISIKO: " + int(min(100, meteorRisk)) + "%", 440, 68); // Produktion, Handel & Notverkauf if (isruBought) { fill(200, 220, 255); textSize(11); text("PRODUKTION:", 20, 95); fill(50, 150, 255); rect(100, 80, 110, 24, 4); fill(255); textSize(10); text("WASSER (15E)", 115, 96); fill(0); rect(220, 84, 60, 16); fill(50, 200, 255); rect(220, 84, map(waterLevel,0,100,0,60), 16); fill(255); text(int(waterLevel)+"%", 285, 96); fill(40, 180, 60); rect(325, 80, 110, 24, 4); fill(255); text("FLORA (20E)", 340, 96); fill(0); rect(445, 84, 60, 16); fill(0, 255, 100); rect(445, 84, map(greenLevel,0,100,0,60), 16); fill(255); text(int(greenLevel)+"%", 510, 96); if (greenLevel >= 10) { fill(180, 50, 50); rect(740, 110, 140, 22, 4); fill(255); text("NOTVERKAUF: -10% Flora", 745, 125); } // Handelspolitik Schalter if (colonistsArrived) { fill(200, 220, 255); textSize(11); text("VERSORGUNG IN: " + int(supplyTimer) + "%", 20, 125); fill(tradePolicy == 0 ? color(0,255,150) : color(255, 80, 80)); rect(160, 110, 200, 24, 4); fill(0); text(tradePolicy == 0 ? "HANDEL: LEGAL (Konsolen)" : "HANDEL: SCHWARZMARKT (Drogen)", 170, 126); if (tradePolicy == 1) { fill(255, 100, 200); text("DROGEN VORRAT: " + int(drugSupply), 375, 126); } } } 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; } if (aiUnlocked && !inRebellion && mouseX > 215 && mouseX < 330 && mouseY > 15 && mouseY < 39) { aiActive = !aiActive; return; } if (mouseX > 70 && mouseX < 150 && mouseY > 48 && mouseY < 70 && !coreBought && tlwEnergy >= 50) { tlwEnergy -= 50; coreBought = true; } if (mouseX > 160 && mouseX < 240 && mouseY > 48 && mouseY < 70) { if (!shieldBought && tlwEnergy >= 70) { tlwEnergy -= 70; shieldBought = true; shieldOn = true; } else if (shieldBought) shieldOn = !shieldOn; } if (mouseX > 250 && mouseX < 330 && mouseY > 48 && mouseY < 70) { if (!defenseBought && tlwEnergy >= 80) { tlwEnergy -= 80; defenseBought = true; defenseOn = true; } else if (defenseBought) defenseOn = !defenseOn; } if (mouseX > 340 && mouseX < 420 && mouseY > 48 && mouseY < 70 && !isruBought && tlwEnergy >= 90) { tlwEnergy -= 90; isruBought = true; } if (isruBought && !balanceReached) { if (mouseX > 100 && mouseX < 210 && mouseY > 80 && mouseY < 104 && tlwEnergy >= 15.0) { tlwEnergy -= 15.0; waterLevel = min(100, waterLevel + 12.0); } if (mouseX > 325 && mouseX < 435 && mouseY > 80 && mouseY < 104 && tlwEnergy >= 20.0) { tlwEnergy -= 20.0; greenLevel = min(100, greenLevel + 12.0); } if (greenLevel >= 10 && mouseX > 740 && mouseX < 880 && mouseY > 110 && mouseY < 132) { 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 > 160 && mouseX < 360 && mouseY > 110 && mouseY < 134) { tradePolicy = (tradePolicy == 0) ? 1 : 0; } } // Fraktal-Schiff if (isruBought && colonistsArrived && !hasSecondShip && mouseX > 650 && mouseX < 870 && mouseY > 15 && mouseY < 37) { if (shipPoints >= 500 && colonistCount >= 50) { shipPoints -= 500; hasSecondShip = true; ship2X = width/2; ship2Y = height/2; triggerStory("FRAKTAL-SCHIFF ONLINE", "Das autonome Schiff hilft dir nun beim Sammeln!"); } } } 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 - 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; } }