// TLW-Modell: H2-Molekül Quantensprung-Minigame (Multi-Orbital & Auto-Aim) float zeit = 0; float p1X, p1Y, p2X, p2Y; float e1Angle = 0, e2Angle = PI; float eRadius = 45; float zielRadius = 45; // Photon-Variablen boolean photonAktiv = false; boolean emissionAktiv = false; boolean photonPralltAb = false; float photonX = -50, photonY = 150; float photonVx = 6; float photonVy = 0; float emissionX, emissionY; float photonWelle = 0; // Interaktive Parameter & Einsteiger-Features float gewaehlteFrequenz = 0.4; // Regler: 0.2 bis 1.1 boolean autoAim = true; // Auto-Aim Modus standardmäßig AN für Anfänger int trefferZaehler = 0; String statusText = "Wähle eine Energie und feuere! Auto-Aim schützt vor Fehlschüssen."; // Definition der 3 Gitter-Resonanzfrequenzen (Diskrete Orbitale) float f_K = 0.45; // K-Schale (Grundzustand) float f_L = 0.72; // L-Schale (Anregung 1) float f_M = 0.98; // M-Schale (Anregung 2) float aktiveResonanz = f_L; // Aktuelles Ziel-Niveau void setup() { size(850, 650); p1X = width/2 - 60; p1Y = height/2 - 40; p2X = width/2 + 60; p2Y = height/2 - 40; } void draw() { background(10); zeit += 0.03; // 1. HEXAGONALES RAUMGITTER stroke(0, 150, 255, 13); strokeWeight(1); noFill(); int schritt = 30; for (int x = 0; x <= width; x += schritt) { for (int y = 0; y <= height - 120; y += schritt) { beginShape(); for (int i = 0; i < 6; i++) { float angle = PI / 3 * i; vertex(x + cos(angle)*16, y + sin(angle)*16); } endShape(CLOSE); } } // Zeichne die 3 verfügbaren stabilen Gitter-Orbitale (Hilfslinien für Anfänger) stroke(255, 200, 0, 12); noFill(); ellipse(width/2, height/2 - 40, 90, 45); // K-Schale stroke(255, 150, 0, 10); ellipse(width/2, height/2 - 40, 170, 85); // L-Schale stroke(255, 50, 0, 8); ellipse(width/2, height/2 - 40, 240, 120); // M-Schale // Sanfte Orbit-Relaxation (Zurückfallen in den stabilen Grundzustand) eRadius = lerp(eRadius, zielRadius, 0.08); if (zielRadius > 45 && !photonAktiv && frameCount % 160 == 0) { zielRadius = 45; emissionAktiv = true; emissionX = (p1X + p2X)/2; emissionY = (p1Y + p2Y)/2; } // 2. PROTONEN (Kerne) & BINDUNG drawProton(p1X, p1Y); drawProton(p2X, p2Y); stroke(0, 255, 200, 30); strokeWeight(4); line(p1X, p1Y, p2X, p2Y); // 3. ELEKTRONEN-ORBITAL (Multi-Schalen Lemniskate) float speedMod = map(eRadius, 45, 120, 0.05, 0.02); // Höhere Orbitale laufen langsamer e1Angle += speedMod; e2Angle += speedMod; // Skalierung der Schleifen-Geometrie je nach Energieniveau (eRadius) float e1X = width/2 + sin(e1Angle) * (eRadius * 2.1); float e1Y = (height/2 - 40) + sin(e1Angle*2) * eRadius; float e2X = width/2 + sin(e2Angle) * (eRadius * 2.1); float e2Y = (height/2 - 40) + sin(e2Angle*2) * eRadius; drawElectron(e1X, e1Y); drawElectron(e2X, e2Y); // 4. ANREGUNG: SPEKTRAL-SINUS-WELLE (Photon) if (photonAktiv) { photonX += photonVx; photonY += photonVy; photonWelle += gewaehlteFrequenz * 0.9; color photonFarbe = holeSpektralFarbe(gewaehlteFrequenz); stroke(photonFarbe); strokeWeight(3); noFill(); beginShape(); for (int i = 0; i < 45; i++) { float faltung = (gewaehlteFrequenz * 0.6); float wx = photonX - i * (photonVx > 0 ? 2 : -2); float wy = photonY + sin(photonWelle - i * faltung) * 14; vertex(wx, wy); } endShape(); // Kollisionsprüfung im Wirkungsquerschnitt des Moleküls if (!photonPralltAb && photonX > width/2 - 35 && photonX < width/2 + 35) { // Bestimme das getroffene Niveau basierend auf der Frequenz boolean trefferK = abs(gewaehlteFrequenz - f_K) < 0.07; boolean trefferL = abs(gewaehlteFrequenz - f_L) < 0.07; boolean trefferM = abs(gewaehlteFrequenz - f_M) < 0.07; if (trefferK || trefferL || trefferM) { photonAktiv = false; trefferZaehler++; if (trefferK) { zielRadius = 45; statusText = "K-SCHALE: Energie hält das Niveau im Grundzustand."; } if (trefferL) { zielRadius = 85; statusText = "L-SCHALE! Erster Quantensprung erfolgreich."; } if (trefferM) { zielRadius = 120; statusText = "M-SCHALE! Maximales Orbital erreicht (Hochenergetisch)."; } aktuelleResonanz = gewaehlteFrequenz; // Speichert Farbe für Emission } else { photonPralltAb = true; photonVx = -4; photonVy = random(-3, 3); statusText = "Abpraller! Frequenz verfehlte alle stabilen Orbitale."; } } if (photonX < -100 || photonY < -50 || photonY > height) photonAktiv = false; } // 5. ENTLADUNG: EMISSION if (emissionAktiv) { emissionX += 7; photonWelle += aktuelleResonanz * 0.9; color emissionsFarbe = holeSpektralFarbe(aktuelleResonanz); stroke(emissionsFarbe); strokeWeight(2.5); noFill(); beginShape(); for (int i = 0; i < 45; i++) { float wx = emissionX - i * 2; float wy = emissionY + sin(photonWelle - i * (aktuelleResonanz * 0.6)) * 12; vertex(wx, wy); } endShape(); if (emissionX > width + 100) { emissionAktiv = false; statusText = "Photon emittiert. Gitter relaxiert zurück in den Grundzustand."; } } // 6. HUD INTERFACE drawInterface(); } color holeSpektralFarbe(float f) { float r = 0, g = 0, b = 0; if (f < 0.45) { r = map(f, 0.2, 0.45, 160, 255); g = 0; b = 40; } else if (f < 0.7) { r = map(f, 0.45, 0.7, 255, 30); g = map(f, 0.45, 0.7, 50, 255); b = 0; } else if (f < 0.9) { r = 0; g = map(f, 0.7, 0.9, 255, 100); b = map(f, 0.7, 0.9, 100, 255); } else { r = map(f, 0.9, 1.2, 100, 200); g = 0; b = map(f, 0.9, 1.2, 255, 235); } return color(r, g, b); } void drawProton(float cx, float cy) { stroke(0, 255, 200, 80); strokeWeight(1.5); fill(12, 24, 40); ellipse(cx, cy, 34, 34); noStroke(); for (int i = 0; i < 3; i++) { float angle = zeit * 2.2 + (TWO_PI/3) * i; fill(i < 2 ? color(255, 65, 65) : color(45, 110, 255)); ellipse(cx + cos(angle)*8, cy + sin(angle)*8, 7, 7); } } void drawElectron(float ex, float ey) { fill(0, 160, 255); noStroke(); ellipse(ex, ey, 10, 10); stroke(0, 160, 255, 60); noFill(); ellipse(ex, ey, 18 + sin(zeit*11)*4, 18 + sin(zeit*11)*4); } void drawInterface() { fill(14, 18, 26); noStroke(); rect(0, 530, width, 120); stroke(35, 48, 68); line(0, 530, width, 530); fill(255); textSize(13); textAlign(LEFT, TOP); text("H₂-MOLEKÜL MULTI-ORBITAL LABOR", 25, 546); fill(0, 255, 180); text("Quantensprünge: " + trefferZaehler, 275, 546); fill(photonPralltAb ? color(255, 100, 100) : color(190, 210, 230)); textSize(12); text("Status: " + statusText, 25, 572); float lambda = 240.0 / gewaehlteFrequenz; float sx = 380; float sy = 574; fill(140, 160, 180); textSize(11); text("λ = " + nf(lambda, 3, 0) + " nm | E = " + nf(map(gewaehlteFrequenz, 0.2, 1.1, 13.6, 120), 2, 1) + " eV", sx, sy - 14); stroke(36, 48, 66); strokeWeight(5); line(sx, sy, sx + 240, sy); // Zeichne alle 3 stabilen Resonanzzonen (K, L, M) als grüne Punkte auf dem Schieberegler stroke(0, 255, 130, 40); strokeWeight(8); point(sx + map(f_K, 0.2, 1.1, 0, 240), sy); point(sx + map(f_L, 0.2, 1.1, 0, 240), sy); point(sx + map(f_M, 0.2, 1.1, 0, 240), sy); // Reglerknopf leuchtet in Photonenfarbe float knobPos = map(gewaehlteFrequenz, 0.2, 1.1, 0, 240); stroke(holeSpektralFarbe(gewaehlteFrequenz)); strokeWeight(13); point(sx + knobPos, sy); strokeWeight(1); // Auto-Aim Schalter für Anfänger fill(autoAim ? color(0, 150, 100) : color(40, 45, 55)); rect(25, 595, 100, 22, 3); fill(255); textSize(10); textAlign(CENTER, CENTER); text(autoAim ? "🎯 AUTO-AIM: AN" : "❌ AUTO-AIM: AUS", 75, 606); // Trigger-Button fill(photonAktiv || emissionAktiv ? 50 : 0, photonAktiv || emissionAktiv ? 50 : 140, photonAktiv || emissionAktiv ? 50 : 220); rect(655, 546, 170, 54, 4); fill(255); textAlign(CENTER, CENTER); textSize(12); text(photonAktiv || emissionAktiv ? "FELD ABSORBIERT..." : "PHOTON FEUERN ⚡", 740, 573); textAlign(LEFT, TOP); } void mousePressed() { // Klick auf den Auto-Aim Schalter if (mouseX > 25 && mouseX < 125 && mouseY > 595 && mouseY < 617) { autoAim = !autoAim; } // Klick auf den Schuss-Button if (mouseX > 655 && mouseX < 825 && mouseY > 546 && mouseY < 600 && !photonAktiv && !emissionAktiv) { // AUTO-AIM INTEGRATION: Findet automatisch die nächstgelegene Schale if (autoAim) { float dK = abs(gewaehlteFrequenz - f_K); float dL = abs(gewaehlteFrequenz - f_L); float dM = abs(gewaehlteFrequenz - f_M); if (dK <= dL && dK <= dM) gewaehlteFrequenz = f_K; else if (dL <= dK && dL <= dM) gewaehlteFrequenz = f_L; else gewaehlteFrequenz = f_M; } photonAktiv = true; photonPralltAb = false; photonX = 0; photonVx = 5.5; photonVy = 0; photonY = (height/2 - 40) + random(-15, 15); statusText = "Welle injiziert..."; } uSlider(); } void mouseDragged() { uSlider(); } void uSlider() { if (mouseX > 380 && mouseX < 620 && mouseY > 555 && mouseY < 595) { gewaehlteFrequenz = map(mouseX, 380, 620, 0.2, 1.1); } }